• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

errors with main class

 
sam johnston
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So I just survived the nightmare of getting everything up and running and I have run into my second problem
Im trying to compile my second app and I get a error saying an exception in the tread "main and a long list of where the eroor is and then it says it cannot find the class
 
PrasannaKumar Sathiyanantham
Ranch Hand
Posts: 110
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
please paste the code and the command prompt output so that we may know what is the error
 
Pushkar Choudhary
Rancher
Posts: 425
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also, be sure to use a meaningful subject line
 
Maneesh Godbole
Saloon Keeper
Posts: 11096
13
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sam,
You can use the button to edit the title.
 
sam johnston
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
Kuldip Shetty
Ranch Hand
Posts: 43
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
set HelloWorldApp.java in classpath while running the java command.

Kuldip
 
Aditya Kanitkar
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This error is related with one of the following
1. Name of the java file and Name of the Java Class is diffrent.
2. The same class is included in a package, but the class is not there in
package named folder.

 
sam johnston
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm sorry for my absolutenoobishness but how would one go about doing that?
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15441
41
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A NoClassDefFoundError almost always means that your classpath is set incorrectly.

The classpath is a list of directories and jar files that Java uses to find *.class files. Normally (by default), Java looks in the current directory for *.class files. When you execute the command java HelloWorldApp, are you in the directory that contains the file HelloWorldApp.class? Did you compile your HelloWorldApp.java source file before you're trying to run it?

Do you have the CLASSPATH environment variable set to anything? If you have, then unset it.

Have a look at Sun's Hello World tutorial, especially the Common Problems page, which also describes the error that you are getting.
 
Aditya Kanitkar
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sam johnston wrote:I'm sorry for my absolutenoobishness but how would one go about doing that?


I didnt get you on this.... What do you mean by that?

You could quote a sentense on which you want to comment.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
[Off topic: When did starting sentences with "so" become trendy? There was actually a thing about it on Quirks and Quarks a few months ago, but I was left unsatisfied.]
 
Janeice DelVecchio
Saloon Keeper
Posts: 1809
12
Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have never had to set my classpath, and I've compiled dozens of applications.

I agree with this:
Aditya Kanitkar wrote:This error is related with one of the following
1. Name of the java file and Name of the Java Class is diffrent.
2. The same class is included in a package, but the class is not there in
package named folder.


Sam, post your code, please.
 
sam johnston
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This seems to be an error with javac I am not even able to generate a .class I have been looking at the tutorial on suns website with no luck. Even downloading their pretyped version of the code still yields me the same error I posted above.
 
sam johnston
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have messed with it some more and here are my results
 
Henry Wong
author
Marshal
Pie
Posts: 21417
84
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sam johnston wrote:I have messed with it some more and here are my results



Well, basically, the error message is pretty self explanatory.

Henry
 
sam johnston
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Indeed that was why I was wondering what was wrong but everything has worked out WOOOT!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic