COMP151 Spring 2017

Lab Instructions

To accompany lectures using Data Structures and Abstractions with Java, 4e, by Frank M. Carrano  as a textbook.

IntelliJ IDEA

IntelliJ IDEA Ultimate Edition ( is installed on all computers in the CS computer labs in Sierra Hall. Students are required to use the tool. CSUCI has a license for the tool. Students must obtain their personal license key by visiting, so they can install and use the tool on their home computers as well. The IntelliJ Tutorial is available with the tool.

IDEA Installation Tips:

  1. First create working folder, for example IDEA_COMP151. This would be the "root" folder for all the labs that we will be working on this semester.
  2. Make sure that you have the latest version of java installed. We are using the latest update of JDK 8. You can download it from .
    • NOTE that IDEA internally utilizes JDK1.6, so you need 1.6 JRE installed as well
  3. Make sure that UML plug-in is enabled


Creating and running your first Comp151 Lab project

Assuming that your IDEA working "root" folder has been created and is called IDEA_COMP151.

For the purpose of this tutorial we will assume that you are working on the Lab01.

  1. Customize four important IDEA settings:
    • set line numbers to be visible: File -> Settings -> Editor -> General -> Appearance
    • set formatting preferences: File -> Settings -> Editor -> Code Style -> Java -> Wrapping & Braces -> Braces Placement. IDEA will use your selected preferences when you want to format the code (Ctrl+A to select all, followed by  Code -> Reformat Code)
    • set java language preferences: File -> Other Settings -> Default Project Structure and set Project language level to "8 - Lambdas, type annotations etc."

    • set SDK preferences: File -> Other Settings -> Default Project Structure and set Project SDK to your highest JDK 8

    • set Tool Windows:

      • View -> make sure that Toolbar, Tool Buttons, Status Bar, and Navigation Bar are checked on

      • View -> Tool Windows -> Structure and you should be able to see the Project and Structure buttons:

      • right click on the Structure button and make sure that Pinned Mode, Docked Mode, and Split Mode are checked on

  2. Create a project in IDEA:
    1. select New Project from the File menu.
    2. select Java
    3. Next
    4. Next
    1. type in the project information as shown below. In the "Project files location" type the root directory location followed by the name of your project:

  1. click Finish
  2. accept the default option Create source directory and click OK
  3. The necessary project structure has been created and you should be able to see the structure of your new project in the Project window:

  1. The instructor provided you with the starting code zipped into Unzip the package to the desktop, for example.

    • Do not put anything yourself into the IDEA_COMP151 folder!

  2. In the Project window, right click on src and select New, in the New menu select Package, in the New Package dialog type the package name (for example Lab01) and click OK:

  1. Open the folder that contains the unzipped files and drag and drop all the .java files into Lab01 package in IDEA project window. IDEA will update all the necessary project information and create all the classes:

  1. Now you are ready to start working on your code. Double click on the class name that you want to work on and the code will appear in the edit panel :


  1. Please refer to IDEA documentation for useful tips on how to work with your project:

  1. When you created the remaining classes and are ready for testing, to run the application right-click on CountHeads and select Run CountHeads.main(). The console window shows now output of your program:

Completing a lab

Each lab counts toward your final grade, so please read the following carefully:

  1. When you are done with a lab please copy all relevant files into a single directory, add the output file, compress the content of the directory into a single ZIP file, and submit the ZIP file in the Blackboard by the due date. Please make sure to submit only the java files that you changed and the relevant output files. All the submitted files must include your name.
  2. The style and neatness of your code will also be graded: