Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

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

0 views
Skip to first unread message

judith

unread,
Nov 4, 2006, 11:08:56 PM11/4/06
to
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

Robert Mark Bram

unread,
Nov 5, 2006, 12:54:12 AM11/5/06
to
Hi Judith,

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

Rob
:)

Simon Brooke

unread,
Nov 5, 2006, 6:51:54 AM11/5/06
to
in message <1162699736....@h54g2000cwb.googlegroups.com>, judith
('jspur...@hotmail.com') wrote:

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

judith

unread,
Nov 5, 2006, 11:29:48 AM11/5/06
to
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:\>

judith

unread,
Nov 5, 2006, 12:14:34 PM11/5/06
to
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

judith

unread,
Nov 5, 2006, 1:35:15 PM11/5/06
to

judith wrote:
> judith wrote:
> > Simon Brooke wrote:
> > > in message <1162699736....@h54g2000cwb.googlegroups.com>, judith
> > > ('jspur...@hotmail.com') wrote:
> > >
> > > > 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.
> > >
> > > --
> > > 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 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

Simon Brooke

unread,
Nov 5, 2006, 4:56:01 PM11/5/06
to
in message <1162744188.4...@h54g2000cwb.googlegroups.com>, judith
('jspur...@hotmail.com') wrote:

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

;; Usenet: like distance learning without the learning.

Oliver Wong

unread,
Nov 6, 2006, 12:44:45 PM11/6/06
to
"judith" <jspur...@hotmail.com> wrote in message
news:1162746874.2...@m73g2000cwd.googlegroups.com...

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


judith

unread,
Nov 6, 2006, 2:44:52 PM11/6/06
to
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

judith

unread,
Nov 6, 2006, 2:44:59 PM11/6/06
to
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
Simon Brooke wrote:
0 new messages