IntelliJ at VTC

This document describes how to set up IntelliJ on your own system for use with Scala development. The software components mentioned below may already set up on the lab machines, but even in the lab you will need to go through some additional steps starting with installing the Scala plugin (the steps before that point can be skipped when setting up a lab machine).

These directions are for IntelliJ 13.1 and Scala 2.11 with Java 8. The instructions for similar versions should be similar.

If you are configuring a lab machine start here. Everything above this point should have already been done in the labs.

To verify that everything is working, clone the WriterDaemon project from GitHub. Open the project in IntelliJ and try building it using the Build -> Make Project main menu item. Try building the executable jar file using the Build -> Build Artifacts main menu item. Open the Ant Build tab (on the right) and right click on the scaladoc target to build the scaladoc for the project. Finally create a ScalaTest run configuration that executes all tests in package edu.vtc.writerdaemon and execute that configuration to verify all tests pass.

If everything worked, you are now all set!

Adding a Module

This describes the steps required to add a module to an exisiting IntelliJ project. You might want to maintain a project for a particular class and add a module for each assignment in that class. Be aware that I also use Git in many of my classes so you might want to create a branch before modifying sample projects I provide.

  1. In the project view on the left side of the main window, click on the name of the project and then select File -> New Module from the main menu. Click on "Scala" in the left pane, "Non-SBT" in the right pane, and then click "Next."

  2. Enter a suitable name for the module such as "Hw01." Verify that the Content Root and Module File Location settings are appropriate. Normally each module is put in a subfolder of the project folder.

  3. Under "Scala Settings" select "Existent Library." Verify that the scala-compiler-2.11 and scala-library-2.11 libraries you previously created are selected. Under "More Settings" be sure "Enable type-aware highlighting" is selected. Click on "Finish" to create the module.

  4. At this point you might want to fine tune the settings of your module a little. Select File -> Project Structure. Then in the left pane under "Project Settings" select "Modules." In the middle pane expand the tree beneath your new module (Hw01 in this example) and click on the Scala facet. Suggested adjustments include: Change the Language level to "Scala 2.11," Enable "Deprecation warnings" and "Unchecked warnings." You might also try "Explain type errors" if you are curious.

Although you now have a new module defined, you might also want to include some code in your module.

  1. In the project view, open the module and right click on the src folder. Select New -> Package. Enter a name such as edu.vtc.cis3030.hw01. Note that package names are traditionally all lower case.

  2. Right click on the name of the package and select New -> Scala Class. Use the name Main for the main object and be sure to change the type to Scala Object (you don't really want a class). Now you can write your main method and whatever else you need. When you are ready to run your program you need to create a run configuration.

  3. In the toolbar you'll find a place where you can select the current run configuration (the list box toward the right hand side of the toolbar). Click on it to pull down the list and select Edit Configurations.

  4. Click on the green "+" in the upper left corner and select "Application". Change the name to "Hw01" (or similar). Be sure the "Classpath to module" is set to the correct module (Hw01 in this case). Set the main class to edu.vtc.cis3030.hw01.Main. You can also browse for the main class, letting IntelliJ find suitable classes (only one right now) for you. Clikc "OK."

You can now compile and run your program by pressing the green arrow next to the run configuration selection box. You can debug your program by pressing the green beetle (right next to the green arrow).

Last Revised: 2014-07-22
© Copyright 2014 by Peter C. Chapin <>