I'm wanted to know how to run several programs for a game under the command prompt

J

judith

Hi it's me again. I got the programs which are 13 of them for a game to
compile using javac *.java but when i want to run the programs using
the main program java projectJS under the command prompt it won't run.
any suggestions. Sorry to keep posting but i can't figure out what to
do Judith Spurlock
 
R

Robert Mark Bram

Hi Judith,
Hi it's me again. I got the programs which are 13 of them for a game to
compile using javac *.java but when i want to run the programs using
the main program java projectJS under the command prompt it won't run.
any suggestions. Sorry to keep posting but i can't figure out what to
do Judith Spurlock

You should post the error messages you are seeing - it is too hard to
guess what is going wrong otherwise. :)

Rob
:)
 
S

Simon Brooke

judith said:
Hi it's me again. I got the programs which are 13 of them for a game to
compile using javac *.java but when i want to run the programs using
the main program java projectJS under the command prompt it won't run.
any suggestions. Sorry to keep posting but i can't figure out what to
do Judith Spurlock

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.
 
J

judith

Simon said:
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.
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)
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:\>
 
J

judith

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)
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)
at the top of each program i put package chapter 14;
and the statement import static chapter14.projectJS
There are 13 programs named WinningsPanel.java , BoardPanel.java.
Suits.java, Players.java
Opponent.java,
GameFrame.java,
Dealer.java
Permutation.java
Card.java
Rank.java
CardOrientation.java
projectJS.java
Deck.java
 
J

judith

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
 
S

Simon Brooke

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.
 
O

Oliver Wong

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
 
J

judith

Thanks to everyone for their help I got the program to run now that i
put it in a subfolder called chapter14 and i ran it as java
chapter14/projectJS and it works now. thanks again Judith
 
J

judith

Thanks to everyone for their help I got the program to run now that i
put it in a subfolder called chapter14 and i ran it as java
chapter14/projectJS and it works now. thanks again Judith
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,017
Latest member
GreenAcreCBDGummiesReview

Latest Threads

Top