Compiling

Before you follow the instructions below, make sure you have this class in a working directory on Eclipse:

public class OddEven {
    
    public static boolean isEven(int n) {
        return n % 2 == 0;
    }
    
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        int number = Integer.valueOf(args[0]);
        if (isEven(number)) {
            System.out.println("Even");
        } else {
            System.out.println("Odd");
        }

    }

}
  1. Download the JDK Development Kit
  2. Open a local terminal (that can be done in several ways, on Eclipse go to Window > Show View > Terminal)
  3. Here’s what my terminal looks like:
  4. Change directory (cd) into your project folder (my working directory is in a folder called CSC210 on my Desktop):
  5. cd into the src folder: cd src
  6. We will compile our .java file first by entering javac OddEven.java into our local terminal
  7. To run our binary code with an argument we can enter java OddEven 2