Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript 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
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

errors with main class

 
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
 
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
 
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
 
Bartender
Posts: 11445
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • 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
 
Ranch Hand
Posts: 45
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
 
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?
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • 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.
 
Author
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.]
 
Bartender
Posts: 1847
14
Eclipse IDE Spring Java
  • 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
 
author
Posts: 23879
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux 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!
 
Do the next thing next. That’s a pretty good rule. Read the tiny ad, that’s a pretty good rule, too.
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic