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. Eclipse is commonly used for enterprise development because many tools are built in. 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; first on the page) 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 first under the IDE Packages) 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, skim through the Welcome window and then close it to get to the typical view of Eclipse.

Eclipse has a lot of different 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 in reminding you about tasks you need //TODO and integrating with Issues repositories, but we need to focus on other views for now.

If you have used Eclipse before or you want to put your code for this course in a specific location, create a new workspace: 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 21 (i.e., JavaSE-21 or similar).
    • Uncheck the box for Create module-info.java file (although it's fine if you do leave it checked; it's for a level or two above what we do
  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 Types to edit the template (or click it and click the Edit button). Then, enter:

    /**
     * ${tags}
     * @author FILL_IN_YOUR_NAME
     */
    

    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.)

Version Control in Eclipse

Configure Git in Eclipse

Eclipse has integrated Git through a project 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