Java Reference
In-Depth Information
as the compiler (
javac.exe
) and JVM (
java.exe
), that you use to develop
and run Java programs. The
jre
(Java Runtime Environment) directories contain
the files needed to run Java programs but not the development tools such as the
compiler. The
jre
would be distributed with a program intended for users who do
not need the development tools. The
include
directory contains files for linking
Java programs to C or C
code (see Chapter 22), and a set of demonstration
programs come in the
demo
directory.
Many of the Java tools such as the JVM (
java.exe
)build on a core in native
code but also use Java classes for higher level tasks. The
lib
directories contain
the JAR files with these classes.
On most platforms, a
PATH
environment variable indicates the location of the
Java executables. For example, the path on a Windows platform might look like:
++
PATH=C:
\
WINDOWS;C:
\
WINDOWS
\
COMMAND;c:
\
java
\
jdk1.5.0
\
bin;
Here the
c:
\
java
\
jdk1.5.0
\
bin
directory contains the
javac
,
java
,
appletviewer
, and other executables. Java programs look relative to this direc-
tory for
rt.jar
,which contains most of the core runtime language classes, and
other JAR files.
The compiler and JVM by default look for user class files in the directory of the
application or applet and its subdirectories (according to the package names). To
find packages in other directories, you can enter the directories in the
CLASSPATH
environment variable or use the
-cp
or
-classpath
notation shown above. For
example, suppose that the file
Bessel.class
is located in
c:
\
programs
\
mymath
\
functions
\
Bessel.class
Then setting the
CLASSPATH
environment variable with
c:
\
> set CLASSPATH c:
\
programs;
provides the location of
Bessel.class
when it is needed, as in the following
subclass definition:
public class MyNewBessel extends mymath.functions.Bessel
{...}
Similarly, when an
import
statement indicates to the compiler what packages
to search for a class, the
CLASSPATH
directs it to the proper directories, as in
import myjava.functions.*;
public class MyNewBessel extends Bessel{..
The
CLASSPATH
can also be set on the command line:
c:
\
> javac -classpath c:
\
programs MyNewBessel
for compilation and
c:
\
>
java -cp c:
\
programs MyNewBessel
Search WWH ::
Custom Search