Skip to main content.

Set Up Eclipse

Objective: Set up Eclipse on Your Computer

Due: Friday before class

Eclipse

Eclipse is a commonly used Java IDE. It can greatly improve your productivity, especially as you learn to use it well. There are other IDEs. Learning one IDE will make learning other IDEs easier.

Installing Eclipse

If you're not using a lab machine, you'll need to install Eclipse.

You can install through the Eclipse installer (which could be helpful) or just install Eclipse directly. There are multiple versions of Eclipse, but you should download the Eclipse IDE for Enterprise Java and Web Developers (the second one on the list) so that you have the same version that is on the lab machines.

Using Eclipse

Start Eclipse. If you're on a lab machine, run Eclipse on the command line by typing eclipse.

Once Eclipse opens, if necessary, close the Welcome window to get to the typical view of Eclipse.

Eclipse has a lot of perspectives. The Eclipse documentation says "Perspectives provide combinations of views and editors that are suited to performing a particular set of tasks. For example, you would normally open the Debug perspective to debug a Java program." Make sure that you're in the "Java Perspective" by going to Window --> Perspective --> Open Perspective --> Java

Close the Task List window in the right pane. Tasks/Mylyn can be very helpful, but it's not necessary at this point, and there is enough other stuff going on.

If you have used Eclipse before, create a new workspace for this course: go to File --> Switch Workspace, choose Other and then make a new workspace directory (e.g., cs209_workspace).

Java Project in Eclipse

  1. In the File menu, create a new Java project using File -> New -> Java Project
    • Name the project FirstProject
    • Make sure the "execution environment JRE" is 17 (i.e., JavaSE-17 or similar).
    • Uncheck the box for Create module-info.java file
  2. You should now see a new Java project (a folder marked with a J) in your Package Explorer view on the left-side of Eclipse, with the name FirstProject
  3. Expand the project to see its (limited) contents. You should see the JRE System Library -- that's on the classpath. You should also see the source folder named src

Configuring Comment Generation

  1. Go to the "Preferences" menu. On a Mac, look under the "Eclipse" menu for "Settings". On Windows, click on the ‘Window’ menu bar option, then choose ‘Preferences’.
  2. In the filter bar, type (or start to type) Code Templates. Click on Code Templates, click on the drop down for Comments in the center pane. Double-click on Overriding methods to edit the template. Then, enter:
    /**
     * ${tags}
     * ${see_to_overridden}
     */
    

    This will give you a good starting point for generating Javadocs for overridden methods. (You'll see.)

Configure Git in Eclipse

Go into Eclipse. Eclipse has a plugin for Git called EGit. Configure EGit to use your GitHub username and password.

  1. Go to the "Preferences" menu. On a Mac, look under the "Eclipse" menu for "Settings". On Windows, click on the ‘Window’ menu bar option, then choose ‘Preferences’.
  2. Type “git” in the filter bar, then choose the path Version Control (Team) > Git > Configuration.
  3. If the following entries don't already exist, click ‘Add Entry...’. Enter user.name as the Key, and your name as the Value, then add another entry with user.email as the Key and your W&L email as the Value.

Using Git within Eclipse

Everything you did in git on the command line, you can do through Eclipse. Hopefully, you're proficient at git, so learning the Eclipse GUI will be relatively easy.

There are two main ways to use Git within Eclipse: through the Team menu and through the Git Staging view.

Open the Git Staging view by going to Window --> Show View --> Other --> Git Staging. You can move the view to whichever pane you like. I tend to put this view in the right pane with Outline.

Open the Git Repositories view by going to Window --> Show View --> Other --> Git --> Git Repositories. You can move the view to whichever pane you like. I tend to put the view in the bottom pane with Problems.

Open an existing (local) git repository

Eclipse Tricks