Eclipse Run As Java Application – NoClassDefFound

I started having a problem in Eclipse trying to run a Java class with a main() method. (Run As… Java Application).

It kept giving me a NoClassDefFoundException on the class I was trying to run. I swear this worked for this project before. It works fine if I create a new Java project.

I finally managed to fix it by adding a missing buildCommand to my .project file.

This was so frustrating that now that I finally figured it out I decided to share it. I’m using Eclipse Indigo on 64-bit Windows 7 by the way.

Before:

<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
  <name>MyJavaProject</name>
    <comment></comment>
    <projects>
    </projects>
    <buildSpec>
    </buildSpec>
    <natures>
      <nature>org.eclipse.jdt.core.javanature</nature>
    </natures>
</projectDescription>

After:

<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
  <name>MyJavaProject</name>
  <comment></comment>
  <projects>
  </projects>
  <buildSpec>
    <buildCommand>
      <name>org.eclipse.jdt.core.javabuilder</name>
      <arguments>
      </arguments>
    </buildCommand>
  </buildSpec>
  <natures>
    <nature>org.eclipse.jdt.core.javanature</nature>
  </natures>
</projectDescription>
This entry was posted in JavaScript by tim.frith. Bookmark the permalink.
tim.frith

About tim.frith

Alfresco Certified Engineer

Senior ECM Consultant
Tim holds a diploma in Computer Systems Technology from Camosun College as well as a Bachelor of Commerce Degree with a Finance specialization from the University of Alberta. He has over 10 years of experience developing web applications with Java as well as extensive database development experience with Oracle, IBM DB2, MS SQL Server, and MySQL.

In recent years he has focused on Enterprise Content Management, with specific training and experience in Alfresco's content management suite.

And finally, Tim is a strong believer that the Edmonton Oilers will soon reclaim their rightful place at the top of the hockey world. Yes, Stanley will once again come to town.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>