Java

In this class we will use Java (Standard Edition). Install this first. In particular, you must install the JDK (Java Development Kit) and not just the Java Runtime Environment (JRE is used in web browsers). If you already have the JDK installed, it doesn't hurt to reinstall, I recommend you do so.

NOTE: Oracle changed the licensing for Java as of January 2019. The instructions below are for the commercial version of Java supported by Oracle. You can use this version without cost for personal code development and test, but you may need to pay a license if you develop software for commercial, business, or production use. This blog gives a description of the licensing changes. You can install an open source version of Java by following these instructions rather the instructions shown next, but the open source version can cause issues with webcam access.

Java installation instructions:

Official documentation and tutorials.

IntelliJ IDEA IDE

We will use the IntelliJ IDEA Integrated Development Environment (IDE) for developing our Java programs.

IntelliJ IDEA installation instructions:

  1. Install Java first, as described above
  2. Download the IntelliJ Community Edition IDE (scroll down a little to find the free community edition) from JetBrains. Note that there is also an Ultimate Edition that is free for students, but despite multiple emails to JetBrains, for some reason they block Dartmouth email addresses :-(. The free and open source Community Edition will suffice for CS10
  3. After downloading, follow the installation instructions
  4. Start IntelliJ and set up a Project to hold your CS10 code
    • Start IntelliJ
    • When a start up screen appears, click "Create new project", otherwise click File->New->Project
      1. Enter project Name as "cs10" [screenshot]
      2. Set project Location to "Documents/IdeaProjects" (or another directory you prefer)
      3. Keep the defaults (Language: Java, Build system: IntelliJ)
      4. Select JDK: 16.02
      5. Click Create
    • Choose to open in "This Window"
  5. Set up folders to organize your CS10 code within the Project
    • Click on the Project name (e.g., "cs10" or the Project name you chose above) in the left pane
    • Click File->New->Directory and give the directory a name (e.g., "day1")
    • Right click on the directory you just created (e.g., "day1") and select Mark directory as -> Sources root
    • Do not skip the preceding step or your code may not run from IntelliJ
  6. Download code from course web page
    • Go to the Schedule tab of the course web page and click on the class date to see the detail page for that class period
    • All of the code for each day will be listed at the top of the detail page
    • Right click on the code you want to download (e.g., "JavaVariables0.java" from the first day of class)
    • Select “Save link as”
    • Select folder where you want to save the code (e.g., "Documents/IdeaProjects/cs10/day1")
    • Click “Save”
    • The file will appear in the left pane under the folder you chose (e.g., "JavaVariables0.java" will be under "day1")
  7. Create your own Java classes
    • Click on the folder where you’d like to store you code (e.g., "day1") in the left pane
    • Click File->New->Java class
    • Give your new class a name that begins with a capital letter (e.g., "HelloWorld") and click "Ok"
    • IntelliJ will create a file called "<your class name>.java" in the directory you chose and will stub out the class for you (e.g., the file will contain "public class <your class name> {}"
    • To add a "main" method (where execution begins)
      • Click inside the curly braces ("{}") of your class in the right pane
      • Type "main" and press enter
      • IntelliJ will expand "main" to "public static void main(String[] args) {}" for you (or you could type this string yourself instead)
    • To add a print statement
      • Type "sout" and press enter
      • IntelliJ will expand "sout" to “System.out.println();” for you (which will save you a lot of typing!)
      • You can add what to print inside the parenthesis “System.out.println(“Hello World!”);”
  8. To run your class (assuming it has a "main" method)
    • Right click on the code in the right pane
    • Select "Run <your class name>.main()"
    • The output will appear at the bottom of the IntelliJ window
  9. You may also want to set up IntelliJ to automatically add import statements
    • In Settings/Perferences select Editor->General->Auto Import
    • Check the "Add unambiguous imports on the fly" checkbox

JavaCV

The "video processing" lecture and a portion of Problem Set 1 use your computer's built-in camera. We will use JavaCV, a Java wrapper around a computer vision tool kit called OpenCV, to access your machine's camera.

JavaCV installation instructions:

If you are having trouble getting WebcamTest.java to run, don't worry, we will get it sorted out.