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 commerical, 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 here.

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. There are two version of IntelliJ IDEA you can use: the Ultimate version (free for students, but you must apply for a license with a Dartmouth email address) or the Community version (slightly stripped down version that is free for anyone). I'll be using the Ultimate version, but the Community version will suffice for CS10.
  3. Click on either the Ultimate or Community version using the links in the previous bullet and follow the installation instructions. Note for Mac users: there appears to be a bug in the latest version of IntelliJ that prevents access to the computer's camera. Please download version 2019.1.4 (scroll down to find this version) instead of the most current version. Windows users should be able to use the most current version without issue.
  4. Start IntelliJ and set up a Project to hold your CS10 code
    • Start IntelliJ
    • If a start up screen appears, click "Create new project", otherwise click File->New->Project
    • Select Java at the top of the left [screenshot]
    • Pick Project SDK to be latest Java version (e.g., 14) at the top of the right pane
    • Take defaults in the right pane
    • Click Next
    • Click Next again (do not click on "Create project from template") [screenshot]
    • Set Project Name to "cs10" and Project location to "Documents/IdeaProjects/cs10" (or another directory you prefer), click "Finish" (you maybe prompted to create a new directory) [screenshot]
    • 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., "Blob.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., "Blob.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.