You should post the error messages you are seeing - it is too hard to
guess what is going wrong otherwise. :)
Rob
:)
Almost certainly some or all of the class files are not on the classpath;
but as Robert has suggested, post the error message and we'll know.
--
si...@jasmine.org.uk (Simon Brooke) http://www.jasmine.org.uk/~simon/
A message from our sponsor: This site is now in free fall
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)
at
java.security.SecureClassLoader.defineClass(SecureClassLoader.java:12
4)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
at java.net.URLClassLoader.access$100(URLClassLoader.java:56)
at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at
sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at
java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
C:\>
Here is the main program and here are the errors that i get when i
compile again using
javac projectJS.java I don't know what to do help!!!
C:\>javac projectJS.java
projectJS.java:13: cannot find symbol
symbol : class WinningsPanel
location: class chapter14.projectJS
public static WinningsPanel winningsPanel =
^
projectJS.java:15: cannot find symbol
symbol : class BoardPanel
location: class chapter14.projectJS
public static BoardPanel boardPanel =
^
projectJS.java:14: cannot find symbol
symbol : class WinningsPanel
location: class chapter14.projectJS
new WinningsPanel();
^
projectJS.java:16: cannot find symbol
symbol : class BoardPanel
location: class chapter14.projectJS
new BoardPanel();;
^
projectJS.java:20: cannot find symbol
symbol : class GameFrame
location: class chapter14.projectJS
GameFrame frame = new GameFrame("Card Game of War",
^
projectJS.java:20: cannot find symbol
symbol : class GameFrame
location: class chapter14.projectJS
GameFrame frame = new GameFrame("Card Game of War",
^
6 errors
> > here is the compile error projectJS.java is the main program that i get when i try to run the program
thanks for any help Judith
>> Almost certainly some or all of the class files are not on the
>> classpath; but as Robert has suggested, post the error message and we'll
>> know.
>>
>> --
>> si...@jasmine.org.uk (Simon Brooke) http://www.jasmine.org.uk/~simon/
>>
>> A message from our sponsor: This site is now in free fall
> 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.
--
si...@jasmine.org.uk (Simon Brooke) http://www.jasmine.org.uk/~simon/
;; Usenet: like distance learning without the learning.
>> C:\>javac *.java
[...]
> at the top of each program i put package chapter 14;
Your package name has to match your directory structure, and your class
name has to match the filename. So if you have a class called "Game" and
it's in package "a.b.c", then your file has to be called "Game.java", and
that file needs to be in directory "a\b\c" to give "a\b\c\Game.java". This
directory hierarchy can otherwise be put anywhere, e.g. "C:\a\b\c\Game.java"
or "C:\MyStuff\a\b\c\Game.java" would both be valid.
Your package name cannot contain spaces, so "chapter 14" isn't a valid
package name. Use "chapter14" instead.
- Oliver