judith said:
here is the compile error projectJS.java is the main program thaks for
any help Judith
C:\>javac *.java
C:\>java projectJS
Exception in thread "main" java.lang.NoClassDefFoundError: projectJS
(wrong name
: chapter14/projectJS)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
OK, as I said, not on the classpath.
You can normally specify the classpath either by using the -cp command flag
of the Java runtime, or by setting an environment variable called
CLASSPATH. The classpath is a list of directories and jar files which
should be searched for classes, for example:
/usr/share/java/xalan.jar:/usr/share/java/xerces.jar:/usr/local/lib/java
Note that on UNIX-like systems elements in the list are separated by colons
but on Windows systems another separator is used - I think the semi-colon,
but check your documentation.
Note also that if your classes are in packages they must be arranged in
directory structures which reflect the package name, so if you have a
package
com.hotmail.spurlock.game
and the class files for that package are in
/usr/local/java/mygame/com/hotmail/spurlock/game
then what goes on the classpath is just
/usr/local/java/mygame
and, conversely, if what you've put on your classpath is
/usr/local/java/mygame
then the class files for the package /must/ be in
/usr/local/java/mygame/com/hotmail/spurlock/game
Hope this helps.