Java Reference
In-Depth Information
This structure appears in your C:\Program Files\Java directory (or C:\Program Files ( × 86)\Java
if you install the 32-bit version of the JDK with a 64-bit version of Windows 7). The jdk1.7.0 directory in
Figure 1-1 is sometimes referred to as the root directory for Java. In some contexts it is also referred to as
the Java home directory. The actual root directory name may have the release version number appended, in
which case the actual directory name is of the form jdk1.7.0_01 , for example. Figure 1-1 shows the funda-
mental subdirectories to the root directory.
The sample directory contains sample applications that use JNLP, which is the Java Network Launching
Protocol that is used for executing applications or applets from a network server without the need for a
browser or the need to download and install the code.
You don't need to worry about the contents of most of these directories, at least not when you get
started. The installation process should add the path for the jdk1.7.0_n\bin directory to the paths defined
in your PATH environment variable, which enables you to run the compiler and the interpreter from any-
where without having to specify the path to it. If you installed the JDK to your C: drive, then the path is
C:\Program Files\Java\jdk1.7.0_n\bin .
A word of warning — if you have previously installed a commercial Java development product check
that it has not modified your PATH environment variable to include the path to its own Java executables. If it
has and the path precedes the path to JDK 7, when you try to run the Java compiler or interpreter, you will
get the versions supplied with the commercial product rather that those that came with JDK 7. One way to
fix this is to remove the path or paths that cause the problem. If you don't want to remove the paths that
were inserted for the commercial product, you have to use the full path specification when you want to run
the compiler or interpreter from the JDK.
The jre directory contains the Java Runtime Environment facilities that are used when you execute a
Java program. The classes in the Java libraries are stored in the jre\lib directory . They don't appear
individually though. They are all packaged up in the archive, rt.jar . Leave this alone. The JRE takes care
of retrieving what it needs from the archive when your program executes.
The CLASSPATH environment variable is a frequent source of problems and confusion to newcomers to
Java. The current JDK does not require CLASSPATH to be defined, and if it has been defined by some other
Java version or system, it may cause problems. Check to see whether CLASSPATH has been defined on your
system. If you have to keep the CLASSPATH environment variable — maybe because you want to keep the
system that defined it or you share the machine with someone who needs it — you have to use a command-
line option to define CLASSPATH temporarily whenever you compile or execute your Java code. You see how
to do this a little later in this chapter.
Search WWH ::




Custom Search