JMU JMU - Department of Computer Science
Help Tools
Using the Java SDK in the Department's Labs


1 Overview

The CS Department's Computer Labs are currently running the Java Software Development Kit developed originally by Sun Microsystems and now maintained/distributed by Oracle.

2 Environment Variables

The SDK uses environment variables for several purposes. These variables must be set before you can begin.

2.1 The CLASSPATH

The CLASSPATH environment variable is used by the compiler and interpreter to locate user-defined packages. Hence, if you want to organize your code into packages/directories you need to add the location of their parent to the CLASSPATH.

Suppose, for example, you have a .java file that begins as follows:

    import animation.*;
    .
    .
    .
    

The Java compiler and interpreter will look for the animation package underneath all of the directories in your CLASSPATH.

BE CAREFUL! If somebody was using a lab machine just before you they may have changed the CLASSPATH. Make sure that you don't accidentally use their code and not yours. The directories in the CLASSPATH are searched in order. So, if their directory appears before yours in the CLASSPATH and you have classes with the same name, their code will be used.

(For other descriptions of the CLASSPATH variable see: The Java Package TutorialClick here for related information from another site. .)

2.2 The PATH

The PATH environment variable contains information about the location of executables. That is, when an executable is invoked at the command line, the command interpreter will search the list of directories in the PATH variable for that executable. If it can't find an appropriate executable it will print a message like:
    The name specified is not recognized as an
    internal or external command, operable program or batch file.    
    

or like:

    command not found
    

3 Working from a Command Shell

Using the Java SDK from a command shell is fairly easy. For help using the command-line tools themselves, you might want to take a look at:

4 Working from within jGRASP

The PATH should be set properly on all machines in the CS Computer Labs. However, you may need to set the CLASSPATH for your particular needs.

The PATH and CLASSPATH can be set inside of jGRASP by clicking on Settings and pulling down to PATH/CLASSPATH

Copyright 2019