p1-sentiments

EECS 285 IntelliJ Setup Tutorial

This tutorial will help walk you through setting up your computer with IntelliJ for Project 1. It is recommended to read through the Project 1 spec before beginning the setup tutorial.

Download and Install

First, download and install the Java Development Kit. Under “Java SE Development Kit 8u181”, select “Accept License Agreement”, and then click on the link for your platform. (If you are on Windows, the most likely one you want is “Windows x64”.)

Next, go to the JetBrains website and download and install IntelliJ Idea Community. Make sure you select Community, not Ultimate.

Set Up Your Computer

Create an EECS 285 folder and a sub folder for Project 1. For example, the file path on my computer looks like this:

/Users/schatzju/Desktop/EECS285_f18/Project1

Configure Code Style

Open IntelliJ. The first time you open it, it will prompt you to setup the IDE. Select “Do not import settings”, choose your theme, and then select “Skip Remaining and Set Defaults”.

Once setup is complete, select “Preferences” from the “Configure” dropdown at the Welcome screen.

Expand “Editor”, select “Code Style”, and type 80 into the “Visual guides” box.

Expand “Code Style”, select “Java”, and change “Tab size” and “Indent” to 2 and “Continuation indent” to 4. Make sure that “Use tab character” is not selected.

Click “OK” at the bottom right.

Create an IntelliJ Project

Select “Create New Project”

Select next.

Select next.

Select the file path that you created in the “Set up your Computer” section. Name the project “Project1”. Select “finish”.

Create a Package

Right click the src folder from the file dropdown on the left side of the screen. You may need to click on the “Project” button on the left to expand the file dropdown.

Select “New”->”Package” from the dropdown menu.

Name the package eecs285.proj1.<uniqname> replacing “<uniqname>” with your own uniqname. It is important that the package is named exactly right!

Your computer’s file system should now look like this.

Move in Starter Files

Move the starter files for Project 1 into src->eecs285->proj1->uniqname. You can do so directly in your operating system’s file explorer. Alternatively, you can select all the starter files in your operating system’s file explorer, including the data folder, and drag them to eecs285.proj1.<uniqname> in the IntelliJ file dropdown. Select “OK” to confirm the move.

Your computer’s file system should now look like this.

Your IntelliJ project window should automatically update and look like this. You may need to click on the triangles to expand the hierarchy.

This is a good time to put the following package directive at the top of each .java file:

package eecs285.proj1.<uniqname>;

Dont forget to change <uniqname> to your actual uniqname! Double click on a source file to open it.

Also replace <uniqname> in the definition of the UNIQNAME constant in TweetSentimentMain with your unqiname.

Create New Java Classes

As mentioned in the Project 1 spec, you will need to add the classes Location and Twitter.

Right click the eecs285.proj1.schatzju package on the file dropdown on the left side of the screen.

Select “New”->”Java Class” from the dropdown menu.

Name the new class.

Follow the instructions in the Project 1 spec to add stubs to the two new classes.

Build and Run Project

The project should now be able to be built and run without errors. The Java program will run using a method called main. For this project, there are two classes that contain a main method, TweetSentimentMain and Test. You can build and run the project from either of these classes.

To run the main in the TweetSentimentMain class, open TweetSentimentMain and right click the green arrow next to either the class name or the main method. Select “Run ‘TweetSentiment…main()’ “.

If it built and ran sucessfully it should print at the bottom of the screen “Process finished with exit code 0”

You can do a similar thing to run Test.java

If it built and ran sucessfully it should print at the bottom of the screen “Process finished with exit code 0”

After doing the above steps, IntelliJ automatically creates configurations that make running the main methods again easier. In the upper-right corner, you can select which main you want to run from the dropdown menu. After you have selected a configuration, you can press the green triangle next to the dropdown to run it again. This can be done no matter what file you are currently looking at!

Setting Command-Line Arguments

You can set command-line arguments by editing a configuration from the dropdown menu in the upper-right corner. Fill in the “Program arguments” box with the desired arguments.