Eclipse Guide

Table of contents:

Installation guide

Step 1: Download

NOTE: if you used Eclipse before, you may have an older version installed. If so, we strongly recommend you uninstall it and install the latest version for maximum compatibility.

You can download Eclipse at eclipse.org/downloads.

Step 2: Installation

  1. Run the Eclipse installer. You should see a window like the one below; Select the first "Eclipse IDE for Java Developers" option.

  2. After that point, you can keep hitting "yes" and select all the default options (unless you want to change something).

    You should eventually see a screen like this. Click the "Launch" button.

Step 3: Configuration

  1. When you run Eclipse, it'll ask you where you want your workspace to be (see screenshot below for example). Your workspace will be the location where Eclipse will add any new projects you create. You can change the location of the workspace if you want: just make sure you remember what you picked.

  2. Once you're done, you should see a "Welcome" screen like below. Close the "welcome" tab to open the regular editor.

  3. Next, select "Windows > Preferences" in the menu. Then, select "Java > Installed JREs":

  4. Click the "Search" button and select the "Java" folder. This folder should contain your installed JRE and JDK. You can probably find this folder located at:

    • Windows: C:\Program Files\Java
    • Mac: /Library/Java

    For example, on Windows:

  5. After hitting "ok", you should see a screen with a line for both the JRE and the JDK. Select the line for the JDK:

  6. Click the "Apply and close" button.

  7. Eclipse, by default, contains a fair degree of clutter. If you want to minimize the clutter, feel free to close the "Task List" and "Outline" tabs/views to the right.

Opening a new project

This section of the guide covers how to open a class project in Eclipse.

  1. First, download and unzip the project from the class website. You can find the download link on project specs page.

  2. Run Eclipse. Select the "File > Import" option from the menu:

  3. Select the "Gradle > Existing Gradle Project" option.

  4. Hit "Ok" and "Next" until you encounter the below dialog. Click the "Browse" button:

  5. Navigate to where your project is located and select it. For example:

Running code

To run code, open the Java file you want to run and click the green circle with the white arrow in the upper middle-left of the screen.

If Eclipse asks you to "select a way to run X.java", select either the "Java Application" or "JUnit Test" options.

You can do the same thing to run unit tests. Once you do run a unit test, you can see the results in the left and lower half of the screen. Click on each test to get more details. For example:

Configuring style checkers

We will start by installing a plugin named 'checkstyle', which, when run, will check your code for different style issues.

  1. In the menu bar, click "Help" > "Eclipse Marketplace"

  2. Search for "checkstyle" (the search bar is near the upper-left). You should now see something like this:

  3. Select the option labeled "Checkstyle Plug-in 8.0.0". Click the "Install" button in the lower-right of that option. You should ignore any other plugins that show up.

    At some point, Eclipse will ask you to accept some license agreements. Accept them, and move on.

  4. Once you are done, Eclipse will tell you that it needs to restart to make sure all changes take effect. Click the "Restart Now" button.

  5. Once Eclipse has finished restarting, we need to load our CSE 373 specific rules.

    Start by downloading and saving our checkstyle rules. Make sure you remember where you saved the file! You probably want to save these rules someplace on your computer that's stable to make sure you don't delete it by accident later.

  6. In the menu bar, click "Window" > "Preferences". Navigate to the "Checkstyle" option. You should see a window that looks like this:

  7. Click the "New..." button. In the window that appears...

    • Set the "Type" to "External Configuration File".
    • Set the "Name" to "CSE 373 Style" (or any other name you want).
    • Set the "Location" to wherever the XML file you just downloaded is located.
    • Check the "Protect Checkstyle configuration file" option at the bottom.

    Your screen should look like this:

  8. After clicking "OK", you should now be back to the "Preferences" window. Select the configuration we just uploaded, and click the "Set as Default" button. Your screen should now look like this:

  9. Click "Apply and Close".

Running style checks

Once your stylechecker is installed, you can run it by right-clicking on your project in the project view pane to the left and clicking "Checkstyle" > "Check Code With Checkstyle".

This will make Eclipse add warnings throughout your files whenever it finds a style violation. However, having to check every file is inconvenient: to see the full list of all style errors, click "Window" (in the menu bar) > "Show View" > "Other...".

In the window that appears, open the "Checkstyle" folder, select the "Checkstyle violations" option, and click ok.

Now, when you run checkstyle, Eclipse should look something like this:

If the warnings are bothering you and you want to clear them for now, right-click the project again, and select "Checkstyle" > "Clear Checkstyle violations".