IntelliJ Setup

Java & IntelliJ Setup

Getting an IntelliJ License

You may start using IntelliJ for free using their free 30-day trial, but we highly recommend signing up for a free student license using this form.

Install IntelliJ

We recommend using the latest version of IntelliJ.

  1. Visit the IntelliJ installer page.
  2. Click on the link for your platform on the right side of the screen (under “Download”) and unzip the downloaded file to extract the Installer.
  3. Run the IntelliJ Installer to install IntelliJ with the default options.
  4. Launch IntelliJ. Allow IntelliJ through your firewall.

Install Maven in IntelliJ (Usually installed by default)

We use a tool called Maven to help setup your projects automatically. Usually IntelliJ has it enabled by default. To check if it is enabled, do:

  1. Open IntelliJ Preferences
  2. On the left sidebar, go to the “Plugins” tab.
  3. Go to “Installed” on the top.
  4. Search for “Maven”
  5. If Maven is enabled, you should see “Maven” and “Maven Extension” plugins. See the below image as well.
    1. If these plugins are not enabled, search for those plugins in the Marketplace and install them before setting up a homework.

Set up homework in IntelliJ

Note: Before starting this, make sure you followed all of the above instructions, including the “Install Maven in IntelliJ” section.

To setup one of the homeworks in IntelliJ:

  1. Download the zip archive off of the homework’s writeup page (for example, hw06.zip).
  2. Unzip that downloaded archive. This should create a folder called, e.g., hw06_local_temp.
  3. Launch IntelliJ.
  4. Press File –> Open…
  5. Navigate to the unzipped archive downloaded created in step 2 and choose the pom.xml file from that directory. IntelliJ should prompt you with: “pom.xml is a project file. Would you like to open the project?” (Say “Open as Project”). Then choose “Trust Project”.

After importing, your Package Explorer should look something like the following:


Install JDK 17 in IntelliJ

We now need to install the Java Development Kit (JDK). Specfically, we’ll download JDK 17, as that’s the version our Autograder uses.

  1. Press File –> Project Structure
  2. In the Project section, press the SDK dropdown and select Download JDK…
  3. Download Version 17 and select Amazon Corretto for the vendor.
    For Mac Users: When choosing your vendor you have to pick between “Amazon Corretto 17.0.14 aarch64” and “Amazon Corretto 17.0.14”. Pick the aarch64 version if your Mac is using an Apple Silicon chip (M1, M2, etc.), and pick the other one if your Mac is using an Intel chip (Macs older than 2020).
  4. Press download and ensure the SDK you downloaded is selected for the project.

Running the Project

To run your project code, you can right-click on your the main class on the left sidebar and run the main class. For example, this would be GUI for hw06 and then click on “Run ‘GUI.main()’”.


Running JUnit Tests

Unit testing is a method of testing source code that verifies that individual units are working properly. A unit of code refers to the smallest testable part of an application. In OCaml, this was a function, and in Java, this is a method. JUnit is a Java package that implements unit testing. IntelliJ provides tools to automate the creation of JUnit tests. It also provides a good interface for running the tests. Together these two tools make systematically testing your program very easy.

To run JUnit tests, right-click on the JUnit testing file that you want to run, then go down to “Run [name of test]”. For example, “Run ‘Image Test’” for Homework 6.


Running the Style Checker

Like OCaml, we have a Style Checker for Java that we will use to grade your code syntax and style. Luckily, you can use the same Style Checker that we have in Gradescope, locally. You can run the style checker by clicking the dropdown next to the Green Play button on the top bar. Then click on “Checkstyle”, then click the Green Play button.


Formatting your Code

To assist passing the Style Checker’s strict style guidelines, we have also provided a formatter in IntelliJ. Similarly to the style checker, this is done using a tool called “Format”, which we have provided to you in the project. It can be found in the same dropwdown menu as the Style Checker.


Using the IntelliJ debugger

For debugging Java code, the IntelliJ debugger can turn out to be more helpful than just using print statements, especially when you start having really complex code. We recommend reading and watching the following resources to learn how to use the IntelliJ debugger:

Additional Java Resources

On the front page of the website, there is a helpful resources tab that links to a range of different guides. We have linked two relevant Java guides below for your reference:

Java Style Guide

Java Testing Guide