reset password

Setting Up Development Environment for CS2011

This guide is for setting up a development environment for CS2011 on Windows. The same environment can be set up on Linux or Mac in a similar way.

Note that if you use a lab computer, you should skip Step 1 as JDK is already installed on the lab computers.

1. Download and Install JDK

Download the latest Java SE Development Kit from Oracle. Double-click on the downloaded file to install it. You may leave all options to default during installation. Pay attention to which folder JDK is installed to as you will need it later -- the default folder is C:\Program Files\Java\jdk-<version>\ (where <version> is a version number like 10.0.2), though you may change it if you want.

After installation, add the bin folder under the JDK folder to the PATH environment variable as follows so you can use the JDK command line tools like javac and java:

Open a File Explore window, right click on My PC and select Properties -> Advanced system settings -> Environment Variables. In the System variables section, double-click on PATH, select New, enter the path of the bin folder under the JDK folder (e.g. if the JDK folder is C:\Program Files\Java\jdk-10.0.2\, then enter C:\Program Files\Java\jdk-10.0.2\bin), then click OK.

To test if JDK is installed correctly, open a Command Prompt and try the following two commands:

> javac -version
> java -version

You should see output like the following:

(JDK After Installation)

A video demonstrating this process is available on YouTube.

2. Download and Use Eclipse

Download the latest Eclipse IDE for Java Developers from Eclipse.org. Unzip the package to a local directory, e.g. c:\eclipse, then start up Eclipse by double-click on eclipse.exe under the Eclipse folder. If you are using Eclipse for the first time, you will be asked to choose a folder to be Eclipse's workspace -- this is the folder where your projects will be stored.

To create a Java program, you first need to create a Java project by selecting File -> New -> Java Project. On the first screen, enter a name for the project -- any name (e.g. cs2011-lab0) will do. Click Next to go to the second screen, and uncheck Create module-info.java file if it's not unchecked already, then click Finish.

After the project is created, right click on the project name and select New -> Class. For testing purpose we'll create a class called Hello, so enter Hello as the class name, check the option public static void main(String[] args), then click Finish. Eclipse will create a Hello.java file. Edit the file so it looks like the following:

public class Hello {
    public static void main(String[] args) {
        System.out.println("Hello in Java!");
    }
}

Right click Hello.java and select Run As -> Java Application, and you should see Hello in Java! displayed in the Console view of Eclipse as shown below:

(Eclipse)

A video demonstrating this process is available on YouTube.

This page has been viewed 4984 times.