Solved

NoClassDefFound error running Java application from Eclipse

Posted on 2011-02-24
12
458 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
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
 
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
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

759 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now