63.

previous chapter table of contents next chapter
  

Java Packages

A typical Java packages error looks like this:

 Exception in thread "main" java.lang.NoClassDefFoundError:      basic/InvalidLookupLocator 

Most of the code in this tutorial is organized into packages. To run the examples, the classes must be accessible from your class path . For example, one of the programs in the basic directory is InvalidLookupLocator.java . This defines the class InvalidLookupLocator in the basic package. The program must be run using the fully qualified path name , like this:

 java basic.InvalidLookupLocator 

Note the use of the period (.), not a slash (/).

In order to find this class, the CLASSPATH must be set correctly for the Java runtime. If you have copied the classes.zip file, the class files for this tutorial are in there. You only need to reference this:

 CLASSPATH=classes.zip:... 

If you have downloaded the source files, then they are all in subdirectories, such as basic , complex , etc. After compilation, the class files should also be in the subdirectories, such as basic/InvalidLookupLocator.class . An alternative to using classes.zip is to set the CLASSPATH to include the directory containing those subdirectories. For example, if the full path is /home/jan/classes/basic/ InvalidLookupLocator.class , then set the CLASSPATH to

 CLASSPATH=/home/jan/classes:... 

An alternative to setting the CLASSPATH environment variable is to use the -classpath option to the Java runtime engine, like this:

 java -classpath /home/jan/classes basic.InvalidLookupLocator 
  


A Programmer[ap]s Guide to Jini Technology
A Programmer[ap]s Guide to Jini Technology
ISBN: 1893115801
EAN: N/A
Year: 2000
Pages: 189

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net