updated: 8/6/18


Since Eclipse is installed in the lab, obtaining it for your home computer is recommended, but not required.

I couldn’t find an official listing of Eclipse’s system requirements. The following specifications are cobbled together from various sites that use Eclipse:

· 512 MB RAM minimum (1 GB RAM recommended)

· 1 GB hard disk space minimum

If your home computer meets the system requirements and you’d like Eclipse for home usage, then read the rest of this section. Otherwise, jump to the next section.

Eclipse is an Integrated Development Environment (IDE) that allows you to enter, compile, and run programs. The programs can be written in one of many different languages. In order to make a particular language work in Eclipse, the language’s compiler must be installed. The compiler installation is separate from Eclipse’s installation.

To obtain the Java compiler, go to this website:


On that website, you’ll see various options for downloading the Java Standard Edition (SE) software. Feel free to read about all the download options and download the ones you want, but the only one you’ll really need is the most recent Java SE 10 JDK download option (JDK stands for Java Development Kit). Click the associated JDK Download link. Using the website’s prompts as a guide, you might have to follow a series of instructions and links in order to find the JDK download link that matches your particular operating system. Click on that link and save the file by downloading it to your computer.

After the download completes, install the JDK as directed. During the installation process, you will be given the opportunity to select different setup options. I accept the default, which is to install everything, but if you want to save space, you should be able to deselect the Source Code, Public JRE, and Java DB setup options.

To obtain Eclipse, go to this website:


Click on the Download button under the Get Eclipse heading and follow the instructions.

After the download completes, install Eclipse as directed. From the menu of installation options, click on the Eclipse IDE for Java Developers option (not the Eclipse IDE for Java EE Developers option). That should generate an installation window. Feel free to accept the default installation folder. For me, the default installation folder was C:\Users\John\java-oxygen, which I don’t like, so I used File Explorer to create a new folder named “eclipse Photon” and then I entered “c:\eclipse Photon” in the installation folder field (I tried to use my hard drive’s root folder and my Program Files folder, but neither of those folders worked due to permissions problems). You can accept your default installation folder or try getting a different folder to work. You should see checkboxes for Create start menu entry and Create desktop shortcut, and those boxes should be selected. Click the Install button. After the installation completes, close the installation window.


· Naturally, you are required to save your program files. In the lab, you are required to save your files on a USB flash drive storage device. If you’re working at home, you may save your save your files on your computer’s hard disk, but you’re still required to have a flash drive so that you can transport your files to and from school. If you’re at the school’s lab, do not use the hard disks ever!


When working on homework assignments, use Eclipse to enter, debug, and run your programs. If you forget how to do something in Eclipse, it is up to you to carefully reread this Eclipse tutorial and figure out how to do things. To reduce the number of rereads, go through this tutorial slowly and try to remember what you’re doing.

This tutorial uses x: to refer to the drive that you’re saving your work on. In the lab, x: should be replaced by the USB drive (assuming that you’re using a USB flash drive storage device). At home, x: should be replaced by the USB drive or the hard drive, whichever you prefer.

Whenever you are asked to perform an action (left column below) that you’ve done before, I will refrain from providing the supplemental information (right column below). If you don’t remember the details of how to do something, look for it earlier in the tutorial. I expect you to have to look up a lot of previously covered material. This is my attempt to force you to start memorizing how to do things.

Actions Supplemental Information
Start Eclipse. Click on the Start menu.

Click on Eclipse.

Create a workspace. Clicking Eclipse (above) should cause a Workspace Launcher dialog to appear.

In the Workspace box, enter x:\219pgms.

Since this is the first time you’ve specified x:\219pgms in the workspace box, you’ll be creating a new workspace – the 219pgms workspace. The 219pgms workspace is contained in the 219pgms folder. If the 219pgms folder doesn’t exist, Eclipse will create it for you automatically.

Make sure the “Use this as a default and do not ask again” box is unchecked.

Click OK.

Clicking OK should cause Eclipse to create the 219pgms workspace and load a Welcome screen.

Go to the workbench. It’s not required, but feel free to explore the Welcome screen’s links.

The workbench is the area where you’ll do all your work – where you’ll enter, debug, and run code. To close the Welcome screen and go to the workbench, click on the screen’s Workbench button in the top-right corner.

If there was no prompt for workspace. If you ever load Eclipse and the Workspace Launcher dialog doesn’t appear, that means someone checked the “Use this as a default and do not ask again” box. That’s a bad thing (particularly in the lab) because then all users are taken to the same workspace location and that location might be inappropriate. To correct this problem, perform these steps after getting to the Eclipse workbench:

Click the Window menu.

Select Preferences.

That should cause a Preferences window to appear.

In the container tree at the left of the Preferences window, expand the General container by pressing the symbol at its left.

Expand the Startup and Shutdown container, and inside the container, select the Workspaces option.

Make sure the “Prompt for workspace on startup” box is checked.

Click Apply and Close.

Make sure you’re using the Java perspective. Eclipse can be used for many different languages. If the previous Eclipse user used it for a language other than Java, switch the Eclipse perspective back to Java.

In the top-right corner of your workspace window, you should see icons for the perspectives that Eclipse has used in the past. You should see a Java perspective icon (look for a J), and it should be selected. If it’s not selected, select it. If you want to select it, but can’t see it as a selection option, select Window / Open Perspective / Other… In the Open Perspective dialog, select Java and then click Open.

Make sure your Java JDK and JRE settings are correct. Click the Window menu.

Select Preferences.

That should cause a Preferences window to appear.

In the container tree at the left of the Preferences window, expand the Java container by pressing the symbol at its left.

Select the Compiler option, which should generate a Compiler frame.

In the Compiler compliance level field, make sure the Java version that you just installed is selected.

In the Java container at the left, select the Installed JREs option. In the Installed JREs frame, make sure the Java version that you just installed is selected. If it’s not displayed as an option to select, use the Add button to search for it and add it.

Click Apply and Close.

How to set coding-style preferences. You’ll now set Eclipse’s coding-style preferences so they match the ICS Program’s coding-style conventions.

Select Window / Preferences.

That should cause a Preferences window to appear.

In the container tree at the left of the Preferences window, expand the Java container and then the Code Style sub-container.

Select the Formatter option.

In the Active profile box, make sure that Java Conventions is selected.

Click the Edit… button.

That should cause a Profile window to appear.

In the Profile window, click the Indentation tab.

In the Tab policy drop-down box, select Spaces only.

In the Indentation size box, enter 2.

In the Tab size box, enter 2.

Make sure that the Align fields in columns box is unchecked.

Make sure all the boxes in the Indent section are checked, except for the Empty lines box.

Click the Braces tab at the top of the Profile window.

For all the boxes except the array initializer box, make sure that Next line is selected.

For the array initializer box, make sure that Same line is selected.

Click the White Space tab at the top of the Profile window.

Expand the Arrays container.

Select the Array initializers option.

Make sure that the after opening brace and before closing brace boxes are unchecked.

The rest of the default code-style formatter profile closely matches the ICS Program’s coding-style conventions, so there’s no need for any more adjustments to it.

In the Profile name box at the top of the Profile window, type ICS Program.

Click OK.

How to set default build path for new Java projects. To keep things simple, you should store your source-code files and your bytecode files in the same folder as the project’s root folder. This step specifies that policy as your default.

In the Preferences window’s expanded Java container, select the Build Path container.

In the Build Path frame, select the Project option.

Click Apply and Close to close the Preferences window.

How to export preferences. I recommend that you put all of your homework into the same workspace. That way you can share your workspace’s coding-style preferences. Nonetheless, there will probably come a time when you’ll want to create a new workspace. When you do so, I recommend that you export your original workspace’s coding-style preferences to an external file and then import that file into your new workspace. Here’s how to export:

Select File / Export….

That should cause an Export window to appear.

In the container tree at the left of the Export window, expand the General container.

Select the Preferences option.

Click Next.

That should cause an Export Preferences window to appear.

Make sure the Export all box is checked.

In the To preference file box, select the folder and file where you want to store your preferences file (I selected x:\eclipse oxygen) and followed by the filename ICS_Profile. Click Finish. Note that a .epf extension is appended to the filename by default.

If you’d like to test that your export worked, shut down Eclipse, open up a new workspace, and attempt to import the ICS_Profile.epf file.

What is a project? A project is an entity that helps to organize all the files in a particular program. A project’s settings are stored in a .project file. The .project file is contained in the project’s folder.
How to organize your projects. I recommend that you use one workspace to store all your CS 219 projects. In this tutorial, you’ve already created a 219pgms workspace and you will create a tutorial project within that workspace. The 219pgms workspace uses a 219pgms folder. The tutorial project will use a tutorial folder which is a subfolder of 219pgms. For your homework assignments, I recommend that you create hw1, hw2, etc. projects within the 219pgms workspace.
Create a project. Select File / New.

In the pop-up submenu, select Project….

That should cause a New Project window to appear.

In the New Project window’s container tree, expand the Java container and then select the Java Project option.

Click on the Next button.

That should cause a New Java Project window to appear.

If someone has previously created an Eclipse Java project (which would be the case if you are in the lab), then, as a shortcut alternative to selecting Project… / New Project, you can select Project… / New Java Project , and that should cause a New Java Project window to appear immediately.

In the Project name box, enter tutorial.

Verify that in the Project layout area, “Use project folder as root for sources and class files” is selected.

Click the Next button.

Click the Finish button.

Verify project creation. Go to File Explorer and locate the x:\219pgms\tutorial folder. Verify the existence of the .project file within the tutorial folder. If you don’t see the tutorial folder, try double clicking on the 219pgms folder.
Find Package Explorer. At the left of your Eclipse window, you should see a Package Explorer pane that contains your workspace’s project folders. If the package explorer pane is not shown, open it as follows:

Select Window / Show View.

Select the Package Explorer option.

Create a source code file. In the Package Explorer frame, right click on the tutorial project.

Select New from the pop-up menu.

Select File from the pop-up submenu.

That should cause a New File window to appear.

In the New File window, select the tutorial folder.

In the File name box, enter Hello.java.

Click the Finish button.

That should cause an empty Hello.java frame to appear in the workbench.

Enter this text: Enter this text in the Hello.java frame such that <your name> is replaced with your actual name.


* Hello.java

* <your name>


* This program says “hello” to the world.


public class Hello


public static void main(String[] args)


System.out.println(“Hello world!”);

} // end main

} // end class Hello

Understand the code. The top section is known as the prologue section. It provides documentation for human readers. The compiler ignores everything between the opening /* and the closing */.

main methods should be enclosed in a class that is public and whose name matches the name of the enclosing file. For example, the main method above is enclosed in a public class named Hello. The class must be named Hello since the enclosing file is named Hello.java.

Save the source file. Click on the save icon (the save icon looks like a diskette).
Compile your program. Click the Project menu.

If the Build Automatically option is checked, click it (so that it becomes unchecked). Click the Project menu.

Select the Build All option or the Build Project option.

If necessary, fix compilation errors. Click the Problems tab at the bottom of the workbench window.

There should be no errors in the Problems frame, but if you entered something incorrectly and there are errors, fix them.

Run the program. Make sure that the cursor is somewhere within your program’s source code.

Click the Run menu.

Select the Run option.

That should cause a progress-bar dialog box to appear (with a fast computer, you won’t be able to see it). The progress bar indicates that a main method is being searched for. The default place to find the main method is in the workbench’s current class (i.e., the class that’s currently displayed). For the current case, the main method is found in the Hello class.

After the progress-bar dialog box disappears, the Console tab should appear in the bottom of the workbench window.

Click on the Console tab.

That should cause Hello world! to appear in the Console frame.

If necessary, fix runtime errors.
Create a second program. To create a new program, you can of course enter it from scratch as you did for the Hello.java program. As a shortcut, this time we’ll copy from an existing program and edit the copy.
Find your program in the Package Explorer pane. In the Package Explorer pane, look for the tutorial container and expand it by pressing the symbol at its left.

In the tutorial container, look for the (default package) container and expand it.

Look for your Hello.java file inside the default package container.

Copy your program. Right click on your Hello.java file.

In the pop-up menu, select Copy.

Right click on the tutorial project.

In the pop-up menu, select Paste.

That should cause a Name Conflict dialog to appear.

In the new name box, enter Countdown (no need to enter the .java extension).

Click OK.

That should cause a Countdown.java file to appear in the tutorial project.

Open the Countdown.java file. Double click on the Countdown.java file.
Edit the Countdown.java file. Edit the Countdown.java file so that it contains this:


* Countdown.java

* <your name>


* This program prints a countdown from a user-entered

* starting position.


import java.util.Scanner;

public class Countdown


public static void main(String[] args)


int startPos; // starting position for countdown

Scanner stdIn = new Scanner(System.in);

System.out.print(“Enter countdown starting position: “);

startPos = stdIn.nextInt();

for (int i=startPos; i>0;)


System.out.println(i + “…”);


System.out.println(“Lift off!”);

} // end main

} // end class Countdown

Ignore resource leak. If you see a warning for the stdIn initialization statement, you can ignore it. If you want an explanation, see http://www.coderanch.com/t/590921/java/java/Scanner-Resource-leak.
Save the Countdown.java source file.
Compile your program. Note that the build commands compile more than just the one file that’s displayed in the source-code frame. The Build All command compiles all the files in your workspace and the Build Project command compiles all the files within your project. At this point, there’s only one project in your workspace, so both build commands compile the same files – Hello.java and Countdown.java.
If necessary, fix compilation errors.
Run the program using the run icon. As a shortcut alternative to using the Run menu, this time, run your program using the run icon. More specifically, look at the top of the workbench for a green-circle icon with a white triangular arrow inside it.

Hover your mouse over the icon.

That should cause the message Run Countdown to pop up.

Click the icon in order to run your Countdown program.

Open the Console frame.

You should see a prompt to enter the countdown starting position. To move your cursor to the prompt area, click within the Console frame. Enter 30.

After pressing enter, your Console frame should be filled with multiple lines of 30…

Why is your Console frame filled with multiple lines of 30… ?

Terminate the program. Your program is repeatedly printing the line 30…

That’s an example of an infinite loop.

Note the red button at the upper-right corner of your Console frame. The red button allows the user to terminate a program that’s currently running. (Makes sense, right? Red for stop.)

To stop the infinite loop, click the red button.

As the program terminates, the red button should become non-red.

Find the error. An infinite loop is an example of a run-time error.

Run-time errors are often more difficult to debug than compilation errors because you do not have the benefit of a compiler-generated error message.

Can you figure out the error?

Do not continue until you attempt to find the error.

Fix the error and recompile. That’s right, the for loop heading is missing its third component.

Replace the for loop heading with this line:

for (int i=startPos; i>0; i–)

Save Countdown.java and recompile.

Run the program. After initiating the run process, you should be prompted to enter the countdown starting position.

Enter 30.

Your Console frame should display this:

Enter countdown starting position: 30

30 …

29 …

<28 through 2 go here>

1 …

Lift off!

Note that you’ll probably need to scroll up and down to see the entire output.

If necessary, fix errors.
Copy the program’s output into a Word document. Next, you’ll learn how to copy your program’s output into a Word document. You’ll need to do this for every homework project.

Use your mouse to select the output (in the Console frame).

Press Ctrl+c to copy the selected text.

Your output is now copied to your computer’s buffer. You’ll next need to paste it into a Word document. Open a new Word document. To paste the previously copied text into the Word document, make sure your cursor is within the Word document and then press Ctrl+v.

Save the Word document in a file named tutorial.docx.

Copy the program’s source code into a Word document. Make sure your cursor is in the Eclipse source code window. Press Ctrl+a to highlight your entire program. Press Ctrl+c to copy the highlighted text. Go to your tutorial.docx Word document. Insert your cursor just prior to your output. Press Ctrl+v to paste your source code just prior to your output. Press the Enter key several times in order to separate your source code from your output.
Apply monospace font to your source code. For every homework project, you’re required to use monospace font for your project source code and project output. Font refers to the appearance of characters. Monospace fonts are fonts such that each character is the same width. Using monospace font ensures that text that’s supposed to be aligned stays aligned when it’s printed. In your homework projects, if your source code or output is not aligned properly, you will lose style points.

To apply monospace font to your Word document’s source code, drag your mouse across the source code so that it becomes highlighted. Use Word’s font name scroll bar to search for Courier New (a popular monospace font), select it, and click OK to apply your font selection.

Apply monospace font to your output.
Save your Word document and Exit from Word.
Exit from Eclipse. Click the X in the top-right corner or select Exit from the File menu.
Start Eclipse This time when you start Eclipse, the Workspace Launcher dialog should display x:\219pgms as the suggested workspace.

Click OK.

That should cause Eclipse to load your 219pgms workspace and your tutorial project.

If the workspace launcher doesn’t work. I’ve found that I’m occasionally unable to reload a workspace. If that happens, use File Explorer to delete the workspace’s .metadata folder. Then (re)create your workspace as described above.
Exit from Eclipse.