Skip to main content

NOTE: You are free to use whatever development environment you want, but CIS 121’s supported IDE is IntelliJ. However, these are former resources from when the course used to support Eclipse.

Eclipse Resources (Setup, Style Checker, Code Coverage, Debugger)

Java & Eclipse Setup

Step 1: Install Java 8

  1. To run Eclipse, a Java Runtime Environment (JRE) must be installed. You can verify that you have the JDK 8 installed by running the `java -version command (from the Command prompt in Windows or the terminal on Mac):

     $ java -version
     java version "1.8.0_101"
     Java(TM) SE Runtime Environment (build 1.8.0_101-b13)
     Java HotSpot(TM) 64-Bit Server VM (build 25.101-b13, mixed mode)
    

    You should see output similar to lines 2-4 above. Any higher version of Java 8 will also work for this class.

  2. If you do not have the JDK 8 installed, you can download it from this site. Select the version for your OS from the table titled “Java SE Development Kit 8u171” (or whatever odd number it’s currently at). Do not download even numbered one, as that one is not a safe build.

    Alternatively, if you are running on macOS and prefer Homebrew, you can use that. Be sure to install Java 8.

    Note: It is best to do this step before installing Eclipse.

Step 2: Install Eclipse

We recommend that you use an Eclipse release version later than Eclipse “OXYGEN”, earlier versions will not work with the style checker. Make sure you have completed Step 1 before installing Eclipse.

  1. Visit the Eclipse download page
  2. Click on the link for your platform on the right side of the screen and install it by simply unpacking the downloaded file onto your desktop.
  3. Launch Eclipse.
  4. The first time you run Eclipse, you need to choose a workspace (a folder that stores your projects).

Step 3: Make Sure Eclipse is Running Java 8

  1. Set Eclipse compiler to compliance level 1.8: Window $\rightarrow$ Preferences $\rightarrow$ Java $\rightarrow$ Compiler. Set the compliance level to 1.8.
  2. Set project compliance level: Click on the project you are working on in the package explorer, then Project $\rightarrow$ Properties $\rightarrow$ Java Compiler. Set the compliance level to 1.8.
  3. Set default Eclipse JRE to Java 8: Window $\rightarrow$ Preferences $\rightarrow$ Java $\rightarrow$ Installed JREs $\rightarrow$ add $\rightarrow$ Standard VM $\rightarrow$ Directory (Find the installed JDK 8 version)
    • The usual location depends on your operating system. You may want to search online if you have issues with this step, or come to OH.
    • If you created a project before setting the default version to 1.8, you will need to update your build path.
  4. Set Execution environment: Window $\rightarrow$ Preferences $\rightarrow$ Java $\rightarrow$ Installed JREs $\rightarrow$ Execution Environment $\rightarrow$ JavaSE-1.8

Setting Up and Using Style Checker Eclipse Plugin

YouTube Tutorial

Style Checker Tutorial

What is the Style Checker Eclipse Plugin?

The plugin is a linter that will highlight code style violations as warnings in Eclipse.

Why use it?

Your code will be graded on style. This plugin allows you to easily spot violations so you can avoid losing easy points on your programming homework. In addition, our style grader on Gradescope will grade based on the configurations set up in the Eclipse plugin. In other words, Gradescope and this plugin will look for the same style violations.

Installing the Style Checker Plugin

NOTE YOU NEED ECLIPSE OXYGEN OR HIGHER TO INSTALL THIS PLUGIN

  1. Download this style checker plugin
  2. Open Eclipse → Help → Install New Software…
  3. Add… → Archive… → Select the downloaded zip file containing the plugin → OK
  4. Select the only checkbox available → Next >
  5. Next > I accept the terms of the license agreement → Finish → Install Anyway
  6. Restart Eclipse

Known Bug In Windows: There is a bug in Windows that occurs if the path to your current project includes a space. If there is a space in the path name, the style checker will not work. Example of a path name with a space (between John and Smith):

C:\John Smith\eclipse-workspace\hw0

If the style checker were being used in the project located in that path, then it will not work. To fix the issue, move the project or eclipse to a folder that does not have any spaces in the path name:

C:\eclipse-workspace\hw0

Using the Style Checker

  1. Select or create a new Java project
  2. Right click on the project → Checkstyle → Activate Checkstyle
  3. Your code should now have warnings if you have style violations

Installing Eclemma (Code Coverage Tool)

There’s a nice tool for automatically determining what parts of your code are covered in Eclipse, called Eclemma. You can install it by following the instructions below:

  1. In Eclipse, click “Help”
  2. Click “Eclipse Marketplace”
  3. Find “Eclemma”, press Enter.
  4. Locate Eclemma and install it
  5. Restart Eclipse

Using Eclemma

Once Eclemma is installed, you can measure coverage by right-clicking on the name of your JUnit test class, then choosing “Coverage As” from the context menu, and then “JUnit Test.”

Once you run the tool, a new view should appear as a tree view. You can expand this view to review the Code Coverage score you got from running the test class.

Eclipse Tutorial Videos (Optional)

For more help, feel free to check out the following tutorial videos!