Setting up Eclipse

Eclipse is a massively powerful work environment. However, "powerful" is often correlated with "complicated" and Eclipse is no exception to the rule. This tutorial will walk you starting up Eclipse, creating a new project, and adding the helper classes that we're going to use in this course to your project. Don't worry. It looks like there's a lot to do, but in reality it's not so bad. By the end of this course you'll know how to do everything in this tutorial in your sleep.

The Workspace

By default, Eclipse will ask you to specify a workspace each time you run it. The workspace is the directory that Eclipse will use as a base. That is, any new folders that Eclipse makes for you will be created in this folder. I suggest that you use a single workspace for all of the homework assignments for this class. If you do, all of your projects will be nicely grouped together automatically.

In the example below, you can see that I've set my workspace to a folder called CSIT 114 on my Desktop. You choose any folder that you like.

Eclipse Workspace Launcher

The Workbench

If you have created a new workspace, then Eclipse will show you a welcome screen. Unless you see something you'd like to explore here, simply close the tab. Otherwise, you will automatically go to the workbench. The workbench can take many different forms; the tabbed windows that appeaer are highly customizable. Depending on the tasks you wish to perform with Eclipse, it is helpful to open some of these tabs and close others. To facilitate the opening and closing, Eclipse has a number of perspectives. You can in the screen shot below that I am in the Java perspective, which shows tools useful for programming in Java.

Eclipse Workbench

To switch among perspectives, click the Open Perspective button in the upper right. A list of recently used perspectives will appear. If the one you are looking for is not on the list, select Other. For this class, we will work in the Dr. Java perspective, which is like the Java perspective but customized for the begining programmer.

Switcing Perspectives

Creating a New Project

Now that we have switched to the Dr. Java perspective, we're ready to create new project. You should create a new project to contain all the files and folders for each of your assignments. To do so, right-mouse click on the Package Explorer, select New and then Project from the drop-down menu. Alternatively, you could select from menu in the top-left File > New > Project.

Creating a new project from the Package Explorer

The next window will ask you to select a project wizard. We will always select Java Project and click Next.

Select the Java Project wizard

Now it's time to name your project. In this example I have called the new project Project 1. Notice that I have also chosen to place the source and output in separate folders by selecting the second radio button under Project Layout. You can elect to do this if you want, but it's not necessary. Generally, it's a good idea to keep your text (source) files from your compiled (binary) bytecode. But all of this is really a matter of style.

Customize the new project

The project wizard has given us a warning at the bottom of the screen. "Using a JRE 1.6 with compiler compliance level 1.4 is not recommended." Indeed, it is not. We are using Java 5.0, so it's important that the compiler uses the rules associated with Java 5.0. Click on Configure Compliance. A Preferences window appears. Select Compiler compliance level 5.0 and click OK. A window will appear to confirm your changes and rebuild your project. Your project is heretofore empty, so it doesn't matter. Click Yes to close the Preferences window. Now you're ready to Finish your project. (Click Finish.)

Change the compiler compliance level to 5.0

Adding Libraries to Your Project

No one likes to reinvent the wheel when it's not necessary. In the software world it rarely is, so we're not going to start from scratch. We're going to use some classes (that you should've already downloaded. If you haven't yet, you can get them here.) To attach them to our project, you need to select from the Eclipse menu Project > Properties > Build Path. Make sure to click on the Libraries tab.

Project Properties Window

I've supplied you with a JAR file that is external to the project. To add it, click Add External JARs. Navigate to the folder containing the file and select it and click Open. Once you've returned to the Properties window, click OK.

External JAR file selection

Now you should see the JAR file listed in the package explorer in the workbench. If you do, then you're ready to rock and roll; i.e., start this week's assignment. Congratulations!

Finished product