Eclipse is a commonly-used IDE for program development in Java.

You should each configure your own Eclipse environment, even if you are working in a team, so do these instructions individually. You can go back to your teams when you return to the main lab exercise.

Starting Eclipse

On many systems there is an icon for you to double-click to start up Eclipse. If you’re using Linux and without an Eclipse icon, enter this at a command-line prompt (the “unix-%” is the operating system prompt, you don’t need to type that, and the "&" tells unix to run the process in the background, letting you continue to use the command prompt):

unix-% eclipse &

Either way, you’ll be prompted to specify a workspace directory; In general, we suggest using the default, which is something like /home/jdfrens/workspace. You’ll have to start Eclipse this way every time you sit down to program. There’s a checkbox you can check so that Eclipse does not continually ask you for your workspace directory; if you didn’t check it this time, you can check it the next time you start Eclipse.

Warning: Eclipse is very particular about its workspaces. Never move or remove projects from a workspace folder unless you use Eclipse itself to do this. Many students try to move a workspace to a new location without Eclipse’s help; really bad things will happen if you do this.

The Windows of Eclipse

The Eclipse Platform will start up with a variety of windows like so:

eclipse

This is a picture of an active Eclipse user.

Creating the Project

Eclipse uses projects to keep different software projects separate. For your purposes, think of everything you do for this lab manual as one project. Java itself provides other ways to keep each lab separate, so using one Eclipse project for every exercise in this lab manual makes a lot of sense.

Creating a project

  1. Right-click in the Package Explorer. (Alternative: select File→New→Project...).
  2. Select Java Project (maybe Java→Java Project), and press Next>.
  3. Enter processing for the Project name; and press Next>. The other values in this dialog window should be fine.
  4. Now click on the Libraries tab and do the following:
    1. Add an external library:
      1. Press the Add External JARs... button.
      2. Browse to the text book’s I/O library found at processingLibraryPath/core.jar and press the Open button. Your instructor will tell you where the Processing library is.
      If you are working in some other environment, you can find this library file in the Processing lib directory.
    2. Add a library provided by Eclipse:
      1. Press the Add Library... button.
      2. Select the JUnit option, and hit the Next> button.
      3. Make sure the JUnit 4 version is selected.
      4. Press the Finish button.
    Your java build path should now include entries for the "JRE System Library", the JUnit library and the core.jar library.
  5. Finally, press the Finish button.
  6. You may be asked by Eclipse if it can rearrange your windows for the "Java perspective". You want this, so say Yes.
Do this...

Follow these directions to create your Processing project. You will add all your packages/classes/prelab questions in the src directory.

You should now see a “processing” in the Package Explorer on the left side of the Eclipse. Expand the project by clicking on the triangle to the left of its folder icon. You’ll see a JRE (“Java Runtime Environment”) entry as well as the classpath variables.

You should have to create only this one project for this lab manual. Your instructor might ask you to create other projects for other work that you do; follow these same steps, changing names as appropriate.

Adding Other Materials to a Project

You can create additional packages, directories and files in your project for various purposes. For example, each new lab and homework assignmen asks you to create a new package to store its folders and files. You can do this as follows:

Creating a package in a project

  1. Select the Package Explorer.
  2. Right-click on the "src" directory in the "processing" project.
  3. Select the New→Package menu item to open the New Java Package dialog.
  4. Enter the Package name. It is common practice to name packages using unique paths, such as edu.calvin.kvlinden.lab08 so that each student's package name is unique. This package name will correspond to the path at which your files are located.
  5. Press the Finish button.

Directories and text files can be created in a similar manner. Text files should have a .txt extension and HTML files should have a .html extension. To edit a text or HTML files, you will probably need to right-click on the file and choose “Open With”-”Text Editor”.

Exporting/Importing Materials out of/into Eclipse

You can use Eclipse’s export and import features to export files out of Eclipse and/or import them into Eclipse. This feature can be useful when sharing code with programming partners.

To share code, the partner who has code exports it and emails it to the other partner, who then imports it.

Back to the top of this page