Solved

NoClassDefFound error running Java application from Eclipse

Posted on 2011-02-24
12
467 Views
Last Modified: 2012-05-11
I am setting up a new computer.  I copied my workspace directory from my old computer to my new computer.  I also copied my Eclipse directory from my old computer to my new computer.  When I run a Java class from Eclipse on my new computer I get a NoClassDefFound error for the class I am running.  When I do the same thing on the old computer it works fine.  I installed the Java SDK from scratch on the new computer.  I also have the new Java SDK in a different directory on my new computer than on my old computer.  I have also tried a bunch of ways to add the directory in which the class files are into the classpath.  I am putting the class files into the default "output" directory under the project's home directory.  This is the default value in Eclipse.  Do you have any suggestions?  I don't understand why Eclipse is not finding the class files.  I also verified that the class files exist under the output directory.
0
Comment
Question by:david_m_jacobson
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
12 Comments
 
LVL 92

Expert Comment

by:objects
ID: 34975706
have you done a clean build of the project
0
 

Author Comment

by:david_m_jacobson
ID: 34975744
yes
0
 
LVL 47

Expert Comment

by:for_yan
ID: 34975798
Do you have all exactly the same paths on your new computer as on the old one?
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 92

Accepted Solution

by:
objects earned 250 total points
ID: 34976135
check your build path configuration
and make sure you're not using an old run configuration
0
 
LVL 20

Expert Comment

by:Sathish David Kumar N
ID: 34976941
Check

windows---->prefrences---> Java--->bulidpath and class path
0
 
LVL 86

Assisted Solution

by:CEHJ
CEHJ earned 250 total points
ID: 34980264
>> I copied my workspace directory from my old computer to my new computer.  I also copied my Eclipse directory from my old computer to my new computer.

That's a good start, but you also need to copy any dependencies too. If your project depends on foo.jar, then foo.jar must be present on the new system, and (unless you reconfigure the build path) it needs to be in exactly the same place in the file system.
0
 

Author Comment

by:david_m_jacobson
ID: 34980346
I confirmed that all the jar files exist on the new computer.
0
 
LVL 92

Expert Comment

by:objects
ID: 34983977
> I confirmed that all the jar files exist on the new computer.

eclipse would tell you if they weren't

Did you create a new run configuration?
What class is it missing
0
 

Author Comment

by:david_m_jacobson
ID: 34984443
I just chose "Run Configuration" from the Run menu and then clicked the "New" button and created a new configuration for the class I was trying to run.  There was no complaint about any missing classes.  I only get an error after I try to run the class.  That is when I get a NoClassDefFound error for the main method of the class I am trying to execute even though I have a main method.
0
 
LVL 92

Expert Comment

by:objects
ID: 34984576
what if u right click on the main class and select Run as>Java App
0
 

Author Comment

by:david_m_jacobson
ID: 35010316
I have not had a chance to test this yet.
0
 

Author Closing Comment

by:david_m_jacobson
ID: 35157199
I had to uninstall my Java JDK and reinstall a 32-bit Java JDK.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Programmer's Notepad is, one of the best free text editing tools available, simply because the developers appear to have second-guessed every weird problem or issue a programmer is likely to run into. One of these problems is selecting and deleti…
Update (December 2011): Since this article was published, the things have changed for good for Android native developers. The Sequoyah Project (http://www.eclipse.org/sequoyah/) automates most of the tasks discussed in this article. You can even fin…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

717 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question