Solved

NoClassDefFound error running Java application from Eclipse

Posted on 2011-02-24
12
462 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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
groupSum5 challenge 5 84
map related example 6 48
Java exception bubble up 2 18
Running JavaFX on JDeveloper 12C 1 32
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…
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…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
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 …

777 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