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

Make sure that you're in the "Java Perspective" by going to Window --> Perspective --> Open Perspective --> Java

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 18 (i.e., JavaSE-18 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

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. 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 GitHub username as the Value, then add another entry with user.email as the Key and your corresponding 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.

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.

This should get you ready for the next assignment. Feel free to play around (e.g., by following the next set of instructions).

Optional: Open an existing (local) git repository

Eclipse Tricks