?
Solved

NoClassDefFound error running Java application from Eclipse

Posted on 2011-02-24
12
Medium Priority
?
474 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
Get real performance insights from real users

Key features:
- Total Pages Views and Load times
- Top Pages Viewed and Load Times
- Real Time Site Page Build Performance
- Users’ Browser and Platform Performance
- Geographic User Breakdown
- And more

 
LVL 92

Accepted Solution

by:
objects earned 1000 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 1000 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
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:
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
Suggested Courses
Course of the Month13 days, 4 hours left to enroll

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