| A path 
              environment variable will indicate on a given platform where to 
              find the JDK or JRE 
              binary executables. For example, the path on a Windows platform 
              might look like   PATH=C:\WINDOWS;C:\WINDOWS\COMMAND;c:\java\j2sdk1.4.0\bin; 
               so that the c:\java\j2sdk1.4.0\bin 
              directory will be searched for java executables. The executables 
              will look relative to this directory for the core class files in 
              rt.jar and 
              other jars. The SDK or JRE installation places directories as follows: 
             
                         
                j2sdk1.4.0____________|_______
 |   |     |   
                |    |
 bin lib   |  demo  |
 |       
                jre
 |      __|__
 include  |     |
 bin 
                  lib
 
 (Typically under the c:\Program 
              Files\Java\ directory on a MS Windows platform. The bin directory contains the set of Java tools, such 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. 
             What about the user class files? When you run java 
              or javac 
              from the command line, the JVM will by default look in that directory 
              and its subdirectories (according to the package names).  To find packages in other directories, you must enter the directories 
              in the CLASSPATH 
              environment variable. For example, suppose that the file Bessel.class 
              is located in   c:\programs\myJava\func\Bessel.class 
              
 Then
  > set 
              CLASSPATH c:\programs;
 will locate Bessel.class 
              such as in the following example subclass definition:
 
 public class 
              MyNewBessel extends myJava.func.Bessel {..
 
 Similarly, when an import statement indicates to the compiler 
              what packages to examine to locate a class, the classpath will direct 
              it to the proper directories
 
 import 
              myJava.functions.*;
 public class MyNewBessel extends Bessel {..
 
 The classpath can also be set in the command line as in :  c:\> 
              javac -classpath c:\programs MyNewBessel for compilation and   c:\> 
              java -cp c:\programs MyNewBessel for running the program.  See Chapter 5: Java : JARS for directions 
              on setting the classpath option to locate classes in JAR files. References and Web Resources Last update: Oct.24, 2004 |