Java program execution and CLASSPATH
Directory hierachy
Directory Hierarchy Consider the figure on the left where the blue rectangles represent the directory hierarchy from the F: drive to a class file named 'MyJava.class' : directory 'A' is contained in the 'F:' drive, directory 'B' in 'A', etc... the MyJava.class file in directory 'web'.

Suppose the 'xyz' and 'web' directories are part of the package of the 'MyJava' class. The full name of the 'MyJava' class is then 'xyz.web.MyJava'.

Java program (class) execution
In a Windows system, you run the program by going to the so called MS DOS Command window, then entering the command line (from any directory):
java  xyz.web.MyJava
In a Unix sytem you can run the program from your user environment.

The CLASSPATH environment variable must point to the directory just above 'xyz', which is 'classes'.

In Windows 95 and 98

In the Windows 9x environment, to point the CLASSPATH variable on the 'classes' directory, you can add the following line to the autoexec.bat file which is directly in the C: drive (not an autoexec.bat file contained elsewhere, except if you boot from another drive):

SET CLASSPATH=%CLASSPATH%;F:\A\B\classes
A semi-colon separates the %CLASSPATH% notation from the directory path identification F:\A\B\classes, with no intervening space. No semi-colon at end of line.

The %CLASSPATH% notation represents the existing value of the CLASSPATH variable. Since the SET command replaces the existing value with the new one, to preserve the existing value, you have to include it in the command.

This line will be taken into account when you restart your computer.

In Windows NT and XP

In Windows NT and XP, you define the CLASSPATH variable from a control panel.