The main tools we will use in this class are the Java programming language and virtual machine, and the Eclipse development environment.
The name Java is used to refer to both the Java programming language, which is the main language we will use in cs2220, the Java bytecode language or JVML, which is the low-level language that is generated by the Java compiler, and the Java runtime environment or a Java virtual machine which is a program that can execute programs in JVML.
To run Java programs, you need a Java runtime environment installed on your computer. You probably already have one installed, since it is used by many web pages. You can test if a Java runtime environment is installed on your computer by following this link: http://www.java.com/en/download/help/testvm.xml. Check that you have the latest version of the Java runtime environment set up on your computer (as of 19 August 2010, this is Version 6 Update 21).
If not, follow this link to install it.
Eclipse is a Java IDE (integrated development environment). It makes designing, developing, and building Java projects more pleasant and efficient than using a separate editor and running the compiler from the command line. There are many different projects that are part of the Eclipse project. For cs2220, we will use the Eclipse IDE for Java Developer (also known as Helios).
Eclipse does not have an installation process. Simply download the package, unzip it to a convenient place (e.g., Program Files\eclipse in Windows) and create a shortcut to the Eclipse executable (for Windows, the file eclipse.exe). The first time you run Eclipse, it will ask you to select a workspace. We recommend you create a “cs2220″ directory in your home directory (e.g., J:\cs2220) and use this as your workspace. You will create new subdirectories for each problem set in that directory.
Creating a Project
To create a new project in Eclipse:
- Open Eclipse by clicking on its executable or the shortcut you created to it. The first time you open Eclipse you will see a special Welcome window. Feel free to explore the options here, but before proceeding you will want to close the Welcome window.
- Inside the Eclipse window, click on File | New | Java Project . The New Java Project dialog box will appear.
- In the Project name: box enter the name of the project (e.g., for PS1 use jfugue). You shouldn’t need to change anything else: the JRE should be selected as JavaSE-1.6, and the Project layout should be Create separate folders for sources and class files. To create the project, click Finish.
You’re all set! You should now see the Package Explorer window, with a folder for the project you created. Click on the arrow before your folder name; it should expand, showing you the src folder that will contain your source code.
Installing a Package
To install a package (as we will need to do to include JFugue in the PS1 project), download the .jar archive file and store it in your workspace. (You may want to create a lib directory and put all the .jar files there.) Then, in Eclipse, right-click on the project name (e.g., jfugue in ps1) in the Package Explorer and select Properties. This pops up the Properties Dialog. In the Properties Dialog, select the Libraries tab. Click Add External JARs…. Select the .jar file you want to install.