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 under the course directory. You can access the course directory from the Start menu.

If you need more help, you can consult Sun's Installation Notes. Or better yet, ask a class mate if they were able to get it set up.

Installation Instructions

  1. Download the files
  2. Click on the download link to open another browser window. Select the SDK column (not the JRE column) for your operating system. Save the installer program, making note of the name and location. I recommend using the "Windows Offline Installation" version of the installer.

  3. Uninstall any prior version of the Java 2 SDK
  4. If you have previously installed another version of the Java 2 SDK, uninstall it. Use the Microsoft Windows Add/Remove Programs utility, accessible from the Control Panel.

  5. Run the installer, using default settings.
  6. For Windows, at the time of this writing, the name of the installer file is j2sdk-1_4_2-windows-i586.exe.

  7. Update the PATH variable so the operating system can find the JDK
  8. Setting the PATH variable may be optional for your system. If you have trouble running Java, then try setting the path. For Windows, see step 5 of the instructions available here.

Compiling and Running Applications

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

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

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

    Compiling a Program

  • Open a window with a command prompt
  • Go to the directory where program source code is stored
  • Type: javac HelloWorld.java
    • May need to prepend the path to javac
  • If no errors, creates HelloWorld.class
    • Type dir to list the files

    Running a Program

  • Type: java HelloWorld
    • May need to prepend the path to java
    • Interpreter loads .class file for HelloWorld
    • Note that .class suffix is not typed
  • Interpreter calls the main method
  • You should see the program output:
  • Hello, World!
    

    More Information

  • Use a Windows Console: instructions on using a DOS console on Windows.
  • Lesson: Your First Cup of Java: detailed instructions for compiling and running your first program

Home | WebCT | Announcements | Schedule | Expectations | Syllabus
Help | FAQ's | HowTo's | Links

Last Updated: August 30 2003 @12:13:34