| Author |
I can compile but can't run
|
Tontang Bei
Ranch Hand
Joined: Oct 21, 2006
Posts: 130
|
|
This is the DotCome game in HFJ. I can compile it but when I try to run it I get the error message D:\MyFiles>java S1 Exception in thread "main" java.lang.NoClassDefFoundError: S1. Below is the code What am I doing wrong? Any help would be welcome
|
 |
Jesus Angeles
Ranch Hand
Joined: Feb 26, 2005
Posts: 2036
|
|
When you put the below on your dos prompt, what do you see? You may have an issue about classpath. You can view the FAQ #9. http://faq.javaranch.com/view?JavaRanchFaq
|
 |
Tontang Bei
Ranch Hand
Joined: Oct 21, 2006
Posts: 130
|
|
This is what I get: D:\MyFiles>set CLASSPATH CLASSPATH=C:\Program Files\Java\jre1.5.0_10\lib\ext\QTJava.zip
|
 |
Jesus Angeles
Ranch Hand
Joined: Feb 26, 2005
Posts: 2036
|
|
Originally posted by Tontang Bei: This is what I get: D:\MyFiles>set CLASSPATH CLASSPATH=C:\Program Files\Java\jre1.5.0_10\lib\ext\QTJava.zip
You should know that that error you had means, that the class file mentioned cannot be found. The classpath should include the folder or path where your classes (those files generated when you compiled your source code) are. The dot character '.' represents the current directory. If the classes are in same folder where you are executing the run, the dot should be in the classpath. For example (Notice the dot after the = sign?): On how to set the classpath, the FAQ might have it. [ February 18, 2007: Message edited by: Jesus Angeles ]
|
 |
Jesus Angeles
Ranch Hand
Joined: Feb 26, 2005
Posts: 2036
|
|
Just a quick fix if your situation is: >>>no package >>>the classes are in the folder where you executed the 'java' to run the program Put this in your dos prompt, press enter, and run again
|
 |
 |
|
|
subject: I can compile but can't run
|
|
|