Results 1 to 9 of 9
  1. #1
    hottea is offline Member
    Join Date
    Jul 2009
    Posts
    5
    Rep Power
    0

    Default how to fix java.lang.NoClassDefFoundError in eclipse

    Hi,

    I have a Java project in Eclipse which has dependency on another library. I added the .jar file to my project but when I create an instance of the class in the library by "new" operator, I got the following exception:

    Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/hivemind/ApplicationRuntimeException

    My question is, how can I fix this exception in Eclipse? Thank yo

  2. #2
    vogella is offline Member
    Join Date
    Aug 2009
    Location
    Heidelberg
    Posts
    47
    Rep Power
    0

    Default

    Did you add the library to the classpath?

  3. #3
    hottea is offline Member
    Join Date
    Jul 2009
    Posts
    5
    Rep Power
    0

    Default

    Thanks for the help! I added the .jar file by:

    Project -> Properties -> Java Build Path -> Libraries -> Add External JARs.

    Is there anything else I need to do? Thanks.

  4. #4
    vogella is offline Member
    Join Date
    Aug 2009
    Location
    Heidelberg
    Posts
    47
    Rep Power
    0

  5. #5
    hottea is offline Member
    Join Date
    Jul 2009
    Posts
    5
    Rep Power
    0

    Default

    No, after doing that, I got the java.lang.NoClassDefFoundError exception.

    If I don't add the jar, I got java.lang.ClassNotFoundException.

    So my question is why I get NoClassDefFoundError after adding the jar and how to fix it.

    thanks.

  6. #6
    vogella is offline Member
    Join Date
    Aug 2009
    Location
    Heidelberg
    Posts
    47
    Rep Power
    0

    Default

    Did you check your jar if it contains the require class? jar is just a zip file which you can open with any Zip tool, e.g. Winzip.

  7. #7
    hottea is offline Member
    Join Date
    Jul 2009
    Posts
    5
    Rep Power
    0

    Default

    Following is the exception I am getting. In the source code, it happens at this line. And both TestClient and ClientBuilder are in the .jar I added.

    public class TestClient {

    private boolean startClient() {
    ...
    clientBuilder = new ClientBuilder(Logger); //<-- exception happens here
    ....
    }

    }




    Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/hivemind/ApplicationRuntimeException
    at TestClient.startClient(TestClient.java:174)
    at ...
    Caused by: java.lang.ClassNotFoundException: org.apache.hivemind.ApplicationRuntimeException
    at java.net.URLClassLoader$1.run(URLClassLoader.java: 200)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.j ava:188)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:3 07)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launche r.java:301)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:2 52)
    at java.lang.ClassLoader.loadClassInternal(ClassLoade r.java:320)
    ... 24 more

  8. #8
    hottea is offline Member
    Join Date
    Jul 2009
    Posts
    5
    Rep Power
    0

    Default

    I forgot to mention I also got this error:

    log4j:WARN No appenders could be found for logger (somepackage.someclass).
    log4j:WARN Please initialize the log4j system properly.

    and the Logger passed in as the parameter is the log4j.Logger type. Could this cause the problem?

  9. #9
    hruday87 is offline Member
    Join Date
    Aug 2009
    Posts
    2
    Rep Power
    0

    Post

    Quote Originally Posted by hottea View Post
    I forgot to mention I also got this error:

    log4j:WARN No appenders could be found for logger (somepackage.someclass).
    log4j:WARN Please initialize the log4j system properly.

    and the Logger passed in as the parameter is the log4j.Logger type. Could this cause the problem?
    These are just warnings not errors i hope, so u need not worry about these 2 mate

Similar Threads

  1. Replies: 1
    Last Post: 04-07-2009, 11:50 AM
  2. Using Eclipse IDE:java.lang.NoClassDefFoundError: main
    By Ms.Ranjan in forum New To Java
    Replies: 6
    Last Post: 12-12-2008, 11:17 PM
  3. Replies: 5
    Last Post: 09-03-2008, 06:29 PM
  4. java.lang.NoClassDefFoundError
    By bizmut in forum Eclipse
    Replies: 3
    Last Post: 06-15-2008, 01:54 AM
  5. java.lang.NoClassDefFoundError
    By J_a_y in forum New To Java
    Replies: 2
    Last Post: 08-07-2007, 12:51 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •