VOTG
[Logo] JavaRanch » JavaRanch Saloon
  Search | FAQ | Recent Topics | Hot Topics
Register / Login


Reply Bookmark it! Watch this topic JavaRanch » Forums » Java » Beginning Java
 
RSS feed
 
New topic
Author

errors with main class

sam johnston
Greenhorn

Joined: Feb 08, 2010
Messages: 14

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

This message was edited 2 times. Last update was at by Maneesh Godbole

PrasannaKumar Sathiyanantham
Ranch Hand

Joined: Nov 12, 2009
Messages: 96

please paste the code and the command prompt output so that we may know what is the error

To err is human,
To forgive is not company policy
Pushkar Choudhary
Ranch Hand

Joined: May 21, 2006
Messages: 353

Also, be sure to use a meaningful subject line
Maneesh Godbole
Bartender

Joined: Jul 26, 2007
Messages: 4244

Sam,
You can use the button to edit the title.

work is the scourge of the drinking class
sam johnston
Greenhorn

Joined: Feb 08, 2010
Messages: 14

Kuldip Shetty
Greenhorn

Joined: Jan 07, 2010
Messages: 21

set HelloWorldApp.java in classpath while running the java command.

Kuldip
Aditya Kanitkar
Greenhorn

Joined: Aug 08, 2009
Messages: 26

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

Joined: Feb 08, 2010
Messages: 14

I'm sorry for my absolutenoobishness but how would one go about doing that?
Jesper Young
Java Cowboy
Bartender

Joined: Aug 16, 2005
Messages: 7862

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.

Java Beginners FAQ - JavaRanch SCJP FAQ
The Java Tutorial - Java SE 6.0 API documentation
Aditya Kanitkar
Greenhorn

Joined: Aug 08, 2009
Messages: 26

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
Bartender

Joined: Sep 29, 2008
Messages: 6873

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

Consultant/Trainer | Polyglottal Developer | Struts Committer/PMC | Struts 2 Web Application Development
Janeice DelVecchio
Bartender

Joined: Sep 14, 2009
Messages: 674

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.

When you do things right, people won't be sure you've done anything at all.
sam johnston
Greenhorn

Joined: Feb 08, 2010
Messages: 14

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

Joined: Feb 08, 2010
Messages: 14

I have messed with it some more and here are my results
Henry Wong
author
Bartender

Joined: Sep 28, 2004
Messages: 10020

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

Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
sam johnston
Greenhorn

Joined: Feb 08, 2010
Messages: 14

Indeed that was why I was wondering what was wrong but everything has worked out WOOOT!
 
jQuery in Action
 
 
Reply Bookmark it! Watch this topic JavaRanch » Forums » Java » Beginning Java
 
RSS feed
 
New topic
The most intelligent Java IDE