?
Solved

NoClassDefFound error running Java application from Eclipse

Posted on 2011-02-24
12
Medium Priority
?
481 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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

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…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
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:
Suggested Courses

650 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