CS 2110 - Eclipse Tips

Eclipse is going to be the IDE (Integrated Development Environment) of choice for this course. Go ahead and get it now, but you're not required to use it until Homework 1. If you want to use JCreator or DrJava at first, that's fine.

We have already put together some Eclipse distributions with the plugins needed for this class. (These are now updated for 2010-2011!) You may download them here:

To download Eclipse from the folks at Eclipse.org:
  1. First be sure that you installed an up-date-date version of the Java SDK (as above)
  2. Visit external link: http://eclipse.org
  3. Click on the orange "Download Eclipse" button
  4. Click on Eclipse IDE for Java Developers link for your operating system.
  5. What you get, specifically, when you download Eclipse is in fact a zip file. To "install" Eclipse, open the zip file and "extract" the files inside it into a new directory.
  6. You can put this new directory anywhere you like (or move it after you unzip it). For Windows users, you can put it into C:\Program Files or C:\Eclipse or anywhere else. For Mac users, you can put it in Applications or anywhere else.
You'll now have a working Eclipse installation. To run Eclipse, go to your newly created eclipse directory and double-click on the Eclipse icon in side the directory. One of the best things about Eclipse is that it doesn't "install." Just copy the directory wherever you want and it still works! To make life easier, however, you can right click on this icon, select "create shortcut", then move the new shortcut to your desktop. To extract files from the Zip file, Windows will do this if you double-click on the Zip file from Windows Explorer (the file-browser). Or, you can download a Zip utility like WinZip (but you don't have to).

The Java code you write will be stored in a separate directory that's called a "Workspace." Make sure you keep up with where you make your Workspaces!

Working with Projects in Eclipse

A Workspace can contain more than one "Project".
  • A Project usually corresponds to a single program, so you might have a Projects namd Homework0, Homework1, etc.
  • A Project organizes your Java files, and Eclipse also adds some other files and folders that it needs and that make things work better.
  • To move your "program" from one machine to another (e.g. from a UVa lab machine to your personal PC), you need to package up the entire Project and then reload it on the other machine.
  • The simplest way is to "Export" a project as a Zip file, then "Import" it on the new machine.
See below for how to Export and Import a Project to a Zip file so you can move your program from one machine to another using email, a USB flash drive, Home Directory, etc.

Warning! You should never run Eclipse on a lab machine with your Workspace set to a folder on UVa's Home Directory (i.e. the K:\ drive)! This will seem to work for a while, but it will fail and you will likely lose all of your work.

Export your project to a zip file

To do this:
  1. Right-click on your project in the Project Explorer and choose Export.
  2. Choose General->Archive File. Click Next.
  3. In the "To archive file:" field, use the Browse button to find a location to save your zip file and to give it a name.
  4. Finally, push Finish. The zip file is where you told it to save.
You can later follow the directions below to re-import your project and pick up where you left off.
Import a zipped project into Eclipse

To do this:
  1. Download the zip file from the link and save it somewhere on either your local or net drive.
  2. Once you have your Eclipse workbench open, select File -> Import.
  3. In the pop-up window, select to import a General -> Existing Projects into Workspace and press Next.
  4. Choose "Select Archive File" (i.e. from a zip file) and choose Browse and find the zip file you downloaded.
  5. Finally, push Finish.
Once this is done, the project shows up in the project explorer.

Note: You can't import a project if one already exists with the same name. If you do have one with the same name that you want to keep, you can delete it or rename it before importing. Right-click on the project in the Eclipse Package-Manager, and choose Delete or Refactor->Rename.