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 Tutorial
.)
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
javac
Command
[invokes the compiler]java
Command
[invokes the interpreter]javadoc
Command
[invokes the documentation generator]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