File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes errors  with main class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "errors  with main class " Watch "errors  with main class " New topic
Author

errors with main class

sam johnston
Greenhorn

Joined: Feb 08, 2010
Posts: 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
PrasannaKumar Sathiyanantham
Ranch Hand

Joined: Nov 12, 2009
Posts: 110
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
Rancher

Joined: May 21, 2006
Posts: 425

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

Joined: Jul 26, 2007
Posts: 10174
    
    8

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


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
sam johnston
Greenhorn

Joined: Feb 08, 2010
Posts: 14
Kuldip Shetty
Ranch Hand

Joined: Jan 07, 2010
Posts: 39

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

Kuldip
Aditya Kanitkar
Ranch Hand

Joined: Aug 08, 2009
Posts: 72
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
Posts: 14
I'm sorry for my absolutenoobishness but how would one go about doing that?
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14074
    
  16

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 7 API documentation
Scala Notes - My blog about Scala
Aditya Kanitkar
Ranch Hand

Joined: Aug 08, 2009
Posts: 72
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

Joined: Sep 29, 2008
Posts: 12617

[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

Joined: Sep 14, 2009
Posts: 1659
    
  11

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
Posts: 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
Posts: 14
I have messed with it some more and here are my results
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18546
    
  40

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
Posts: 14
Indeed that was why I was wondering what was wrong but everything has worked out WOOOT!
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: errors with main class
 
Similar Threads
Insert 2nd class tu main class
Installing JDK in Windows 7
Calling main method
Jar file help
can there be more than one main method in a java program