Java
The current version of Java (Standard Edition) is version 8. Install this first. In particular, you must install the JDK (Java Development Kit) and not just the Java Runtime Environment (JRE, used e.g., in web browsers). Doesn't hurt to reinstall, so do.
- Hit the JDK download button at the Oracle download site [screenshot]
- Accept the license agreement (read it first if you're so inclined). [screenshot]
- Click the download link for your platform. [screenshot]
- Install the download in the usual way for your platform, following the instructions.
Official documentation and tutorials.
Eclipse
We are using the Eclipse environment for developing our Java programs. Installation instructions:
- Install Java first, as described above.
- If you already have Eclipse installed, it's easiest to just throw it away. If you have a workspace you want to save, you might want to move / rename it for now, and create a new one as described below.
- Follow the links to download Eclipse
- An installer will be downloaded to wherever you keep downloads. Run it.
- Select "Eclipse IDE for Java Developers" (not Java EE Developers) [screenshot].
- The default installation directory is probably fine. Note that that's where the program will "live", so you might want to make a shortcut to it.
- Once it's installed, launch it!
- Select a workspace; the suggestion is fine. Check the box to use it as a default. [screenshot]
- A splash screen will appear. Click the "Workbench" icon in the upper left. You can uncheck the button to skip this screen in the future. [screenshot]
- Now you're in the "integrated development environment (IDE)"! [screenshot]
- Go ahead and set up a Java project named "cs10" to hold the files for this class. Menu "File" — "New..." — "Java Project". Give it a name (cs10) and accept the defaults for the other options, and hit the "Finish" button. [screenshot]
- You can customize the windows (panes) as you desire.
Notes for basic usage of Eclipse in CS 10 (helpful hints are posted on Piazza; please add your own!):
- I recommend creating only a single project, the cs10 project described above, and keeping all your code there.
- But you can organize separate source folders, e.g., one per major topic in class, one for each problem set, etc. Create these with menu "File — new source folder" (note that it has to be a source folder, not a regular folder, for Eclipse to know to compile the code).
- Code in any source folder in the project can use code from any other folder in that same project. So there's no need to copy stuff that gets used in different place. And in fact, you can't, since Eclipse doesn't allow two files of the same name.
- While Eclipse wants you to put code in a "package" other than the default one, don't, at least for the problem sets. That causes pain for the TAs, who then have to deal with everyone's different package set-up.
- To bring in the code from class, download the file and directly drag it into a source folder. Things can go funky you try to create a new file and copy-paste into it; downloading and dragging ensures you have exactly what I have, with exactly the same filename (capitalization and all). Similarly with images.
- Eclipse allows you to specify relative pathname for files. See the examples from class, e.g., "pictures/smiley.png" refers to a file named "smiley.png" inside the "pictures" folder in your cs10 project (create this folder by menu "File — new folder"). Do not hard code the full path (e.g., "/Users/cbk/Documents/workspace/..."), as again that won't be the same for the TAs.
- If there are red 'x'es in the code, don't try to run it. If it does run, it's actually an old version and not the code you're actually looking at.
JavaCV
The "video processing" lecture, and a portion of Problem Set 1, make use of JavaCV, currently at version 1.2. It is installed on Sudikoff Lab machines, but you might want to install it on your machine too. If you have problems, look/post on Piazza, and use the lab machines until it gets straightened out.
- Download and extract the files from the zip archive: javacv-1.2-bin.zip.
- In Eclipse, open up the "cs10" project you created above. Go to menu "Project" — "Properties" — "Java Build Path" and select tab "Libraries". [screenshot]
- In that panel, click button "Add External JARs..." and add three JARs from the zipfiles: "javacpp.jar", "javacv.jar", and "opencv-[sys].jar" (macos, windows, or linux, as appropriate). Windows users may also need to add opencv.jar in addition to opencv-windows.jar. [screenshot]
- To test the webcam, save the file WebcamTest.java and drag it to the "src" folder in the "cs10" package. [screenshot]
- If there are red 'x'es, there's an installation problem, most likely the JAR files aren't correctly added.
- Click the green "go" button to run it, and cross your fingers.
- Unfortunately, I haven't found a way to make exactly the same code that works on my Mac also work on everybody else's Windows boxes. So if you have a Mac, this code should work. If you have a Windows machine, it might work. If not try changing the "true" in line 21 to "false" (no quotes around the word though). If still not, please post on Piazza.
- Note to Windows 10 users: in Settings — Privacy — Camera, make sure "Let apps use my camera" is switched to "On".
- Additionally, at least one user needed to make changes specified here in order to run OpenCV on a new Windows machine.