This week's book giveaway is in the Android forum.
We're giving away four copies of Learning Java by Building Android Games and have Jean-Marcel Belmont on-line!
See this thread for details.
Win a copy of Learning Java by Building Android Games this week in the Android forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • Devaka Cooray
Saloon Keepers:
  • Ganesh Patekar
  • Tim Moores
  • Carey Brown
  • Stephan van Hulst
  • salvin francis
Bartenders:
  • Ron McLeod
  • Frits Walraven
  • Pete Letkeman

I can compile but can't run  RSS feed

 
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 2085
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 130
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2085
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 2085
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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

 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!