User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Java section within the Software Development category of DaniWeb, a massive community of 402,750 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,444 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Java advertiser: Lunarpages Java Web Hosting
Views: 100109 | Replies: 58
Reply
Join Date: Jul 2005
Posts: 2
Reputation: brian_cal is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
brian_cal brian_cal is offline Offline
Newbie Poster

Re: Exception in thread "main" java.lang.NoClassDefFoundError: Invaders Error

  #41  
Jul 27th, 2005
Hey guys here are my Environmental Variable settings same problem as most of you compiles fine but same error at runtime

CLASSPATH C:\j2dk\lib\comm.jar;C:\j2dk\lib\tools.jar;
also tried %classpath%;C:\j2dk\lib\comm.jar;C:\j2dk\lib\tools.jar;

PATH C:\j2dk\bin

tried moving .class file to C:\j2dk\bin but still no joy at runtime

Thank you in advance

Brian
Reply With Quote  
Join Date: Jun 2005
Posts: 14
Reputation: rpratt is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 0
rpratt rpratt is offline Offline
Newbie Poster

Re: Exception in thread "main" java.lang.NoClassDefFoundError: Invaders Error

  #42  
Jul 27th, 2005
Try this (I have no idea why it works):

For Classpath: type a period, and only a period. Really - it works!
Reply With Quote  
Join Date: Nov 2004
Posts: 229
Reputation: sam1 is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 0
sam1's Avatar
sam1 sam1 is offline Offline
Posting Whiz in Training

Re: Exception in thread "main" java.lang.NoClassDefFoundError: Invaders Error

  #43  
Jul 27th, 2005
hi

i had this error i think twice. once the footpath wasnt set properly and the other time i compiled a class with no main.

so check for these two,

:mrgreen:
Reply With Quote  
Join Date: Nov 2004
Location: Netherlands
Posts: 5,700
Reputation: jwenting is a jewel in the rough jwenting is a jewel in the rough jwenting is a jewel in the rough jwenting is a jewel in the rough 
Rep Power: 18
Solved Threads: 195
Colleague
jwenting's Avatar
jwenting jwenting is offline Offline
duckman

Re: Exception in thread "main" java.lang.NoClassDefFoundError: Invaders Error

  #44  
Jul 27th, 2005
you should NEVER EVER put classes or jars from the JDK installation in your classpath.
It's not needed and can cause problems.

You SHOULD put the current directory ('.') in there or else pass it as a classpath to the java compiler and runtime always.

If you still get a NoClassDefFoundError you're missing something on your classpath, which will pretty much always be a library you need for some import or other.
42 Private messages asking for help will be ignored
In the frozen land of Nador they were forced to eat Steve's iMinstrels, and there was much rejoicing.
Reply With Quote  
Join Date: Jun 2004
Location: H4x0rville
Posts: 2,105
Reputation: server_crash is on a distinguished road 
Rep Power: 9
Solved Threads: 18
server_crash's Avatar
server_crash server_crash is offline Offline
Postaholic

Re: Exception in thread "main" java.lang.NoClassDefFoundError: Invaders Error

  #45  
Jul 27th, 2005
Originally Posted by jwenting
you should NEVER EVER put classes or jars from the JDK installation in your classpath.
It's not needed and can cause problems.

You SHOULD put the current directory ('.') in there or else pass it as a classpath to the java compiler and runtime always.

If you still get a NoClassDefFoundError you're missing something on your classpath, which will pretty much always be a library you need for some import or other.

You should have said something earlier before I led these people on for 40 posts!!!
Reply With Quote  
Join Date: Jul 2005
Posts: 2
Reputation: brian_cal is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
brian_cal brian_cal is offline Offline
Newbie Poster

Re: Exception in thread "main" java.lang.NoClassDefFoundError: Invaders Error

  #46  
Jul 27th, 2005
To remove all doubt on this issue I said I'd post the following link I found.

http://www.cs.ucsb.edu/~teliot/Path_and_Classpath.htm

It gives a retard proof(well it did work for me) guide to how to properly configure the environmental variables when installing java.

enjoy.
Reply With Quote  
Join Date: Nov 2004
Location: Netherlands
Posts: 5,700
Reputation: jwenting is a jewel in the rough jwenting is a jewel in the rough jwenting is a jewel in the rough jwenting is a jewel in the rough 
Rep Power: 18
Solved Threads: 195
Colleague
jwenting's Avatar
jwenting jwenting is offline Offline
duckman

Re: Exception in thread "main" java.lang.NoClassDefFoundError: Invaders Error

  #47  
Jul 27th, 2005
It also has some serious errors...
1) you don't need to restart your computer when you're running XP, NT, or Win2K.
2) you should set JAVA_HOME and refer to that in your path instead of the full installation directory. Many applications expect JAVA_HOME to be set and it also makes upgrading a lot easier
3) of course the actual directory to set depends on the exact JDK version you're using and where you install it.

But apart from that it's a nice checklist
42 Private messages asking for help will be ignored
In the frozen land of Nador they were forced to eat Steve's iMinstrels, and there was much rejoicing.
Reply With Quote  
Join Date: Jul 2005
Posts: 17
Reputation: techy is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 0
techy techy is offline Offline
Newbie Poster

Re: Exception in thread "main" java.lang.NoClassDefFoundError: Invaders Error

  #48  
Jul 27th, 2005
Hi,
Just try to set the classpath in the path of the folder where u r trying to compile.
Just try by setting the classpath in the command prompt
C:\xyz\234>set classpath =%classpath%;.;
and then execute the class again there
C:\xyz\234>java brian
techy :)
Reply With Quote  
Join Date: Oct 2005
Posts: 1
Reputation: Red Adare is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
Red Adare Red Adare is offline Offline
Newbie Poster

Re: Exception in thread "main" java.lang.NoClassDefFoundError: Invaders Error

  #49  
Oct 12th, 2005
Assuming you are using J2SDK you the class files for lang etc., are in the tools.jar file. You therefore need to add this file to your CLASSPATH.
E.g.,

.;c:\j2sdk1.4.1_02\bin;c:\j2sdk1.4.1_02\lib;c:\j2sdk1.4.1_02\lib\tools.jar

Simply replace j2sdk1.4.1_02 with whichever SDK you are using. Search for the tools.jar file if you are unsure where to look.
Reply With Quote  
Join Date: Feb 2006
Posts: 1
Reputation: cscottrun is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
cscottrun cscottrun is offline Offline
Newbie Poster

Re: Exception in thread "main" java.lang.NoClassDefFoundError: Invaders Error

  #50  
Feb 1st, 2006
I had this same problem and was able to resolve it by simply re-saving the .java file with a different name and recompiling.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb Java Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the Java Forum

All times are GMT -4. The time now is 8:09 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC