<< Back

How To Install Java

On This Page


Introduction

Here are some instruction for setting up the Java Software Development Kit (JDK or Java SDK) at home. Java is already installed on CTC and lab machines. If you need more help with the installation, you can consult the Platform Installation notes or the tutorial: Lesson: The "Hello World!" Application. Or better yet, ask a class mate if they were able to get it set up.

For Mac users, go to Mac OSX Updates and search for Java to verify you have the most recent update for the Mac. You need Java version 6 or later.

For Linux users, see the Platform Installation instructions and follow the link to 32 bit or 64 bit Linux. You need the full JDK version as the JRE does not have all the software tools needed for developing programs.

Installation Instructions for Windows

  1. Uninstall any prior version of Java
  2. If you have previously installed another version of Java, uninstall it. From the Control Panel use the Add/Remove Programs utility on XP (or earlier) or the Programs and Features utility on Vista or later.

  3. Uninstall any version of QuickTime.
  4. Apparently, if you install QuickTime without first installing Java, QuickTime installs an older version of Java. However, if you install Java before installing QuickTime, then QuickTime uses the more up-to-date version you are now installing. By NOT following this step, QuickTime sets a classpath to the older version of Java that will interfere with the operation of a newer version of Java.

  5. Download the JDK files
  6. Click on the download link to open another browser window. Download the Java Platform (JDK) (not the JRE) for your operating system. You should install the latest version of the Java Platform (JDK). Do NOT install the bundles, NetBeans or Java EE. Save the installer program, making note of the name and location. If you are installing to Windows, I recommend using the "Windows Offline Installation" version of the installer.

  7. Run the installer, using default settings.
  8. For Windows, at the time of this writing, the name of the installer file for windows is jdk-6u21-windows-i586.exe.

  9. Update the PATH variable so the operating system can find the JDK
  10. The PATH is the system variable that your operating system uses to locate needed executables from the command line or Terminal window. For instructions, see How do I set or change the PATH system variable?.

Compiling and Running Applications

After installing the Java SDK, you should compile and run a sample program to verify the installation. One simple program you can compile and run is the HelloWorld.java program shown below:

import java.util.Scanner;

public class HelloWorld {
    public static void main(String[] args) {
        System.out.println("Hello, world!");
    }
}

Copy this file into a text editor (e.g. Notepad or TextPad) and save it in a convenient location. Then follow these instructions:

Running CheckStyle from the Command Line

CheckStyle is a program to check the style of your Java documentation. Here are some instructions for running CheckStyle at the command line:

  1. Copy the checkstyle-all-4.4.jar and grade_checks.xml into the same directory as your Java source files.

    I am using CheckStyle 4.4 for grading this semester because this is the version installed in the CTC.

  2. Open a console (terminal) window and type the following command:

    java -jar checkstyle-all-4.4.jar com.puppycrawl.tools.checkstyle.Main -c grade_checks.xml *.java

This will test all the *.java files in the directory. If you want to restrict the files you will need to specify the file name rather than use *.java.

<< Back