Results 1 to 8 of 8
  1. #1
    senca is offline Member
    Join Date
    Feb 2010
    Posts
    36
    Rep Power
    0

    Default java.lang.noClassDefFoundException using JDom2

    Hey all,

    I am tryng to create a jarfile which has always worked until now.
    I am using the JDom jar's for xml and when trying to execute the jar from the terminal I get this:

    Exception in thread "main" java.lang.NoClassDefFoundError: org/jdom2/JDOMException
    Caused by: java.lang.ClassNotFoundException: org.jdom2.JDOMException
    at java.net.URLClassLoader$1.run(URLClassLoader.java: 217)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.j ava:205)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:3 21)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launche r.java:294)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:2 66)
    Could not find the main class: SettingsScreen. Program will exit.

    I've searched the web and I find information but I'm pretty new when it comes to classpaths and stuff like that so basically I do not know how I can solve this.
    Any assistance would be very very much appreciated since this really bugs me and I do not own the skill to solve it myself.

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,562
    Rep Power
    25

    Default Re: java.lang.noClassDefFoundException using JDom2

    Where is the definition for that class? Is its class file in some jar file? If you have the jar file with the missing class file, you can use the Class-Path: entry in the manifest file that goes into your jar file to refer to the jar file with the missing class. Put all the jar files in the same folder.
    If you don't understand my response, don't ignore it, ask a question.

  3. #3
    senca is offline Member
    Join Date
    Feb 2010
    Posts
    36
    Rep Power
    0

    Default Re: java.lang.noClassDefFoundException using JDom2

    The manifest in the jar only contains these lines:

    Manifest-Version: 1.0
    Created-by: GJar (Welcome | Daik.se)
    Main-Class: SettingsScreen

    edit:

    the jar content contains all my own classfiles, the meta-inf folder and the 5 jdom jar files. All immediatelly inside the same jar.
    Last edited by senca; 05-10-2012 at 07:01 PM.

  4. #4
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,562
    Rep Power
    25

    Default Re: java.lang.noClassDefFoundException using JDom2

    Did you try adding the Class-Path: entry to your manifest file?
    The java program does NOT use jar files contained inside of other jar files. The jar files need to all be outside of any jar file.
    If you don't understand my response, don't ignore it, ask a question.

  5. #5
    senca is offline Member
    Join Date
    Feb 2010
    Posts
    36
    Rep Power
    0

    Default Re: java.lang.noClassDefFoundException using JDom2

    Quote Originally Posted by Norm View Post
    Did you try adding the Class-Path: entry to your manifest file?
    The java program does NOT use jar files contained inside of other jar files. The jar files need to all be outside of any jar file.

    So I can kick al the internal jars out?

    What exactly do you mean with adding the classpath?

  6. #6
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,562
    Rep Power
    25

    Default Re: java.lang.noClassDefFoundException using JDom2

    Sorry, where did I say to add classpath?

    jar files in a jar file are not used by the java command.
    If you don't understand my response, don't ignore it, ask a question.

  7. #7
    senca is offline Member
    Join Date
    Feb 2010
    Posts
    36
    Rep Power
    0

    Default Re: java.lang.noClassDefFoundException using JDom2

    Quote Originally Posted by Norm View Post
    Sorry, where did I say to add classpath?
    "Did you try adding the Class-Path: entry to your manifest file?"

    I guess I misunderstood this line.

  8. #8
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,562
    Rep Power
    25

    Default Re: java.lang.noClassDefFoundException using JDom2

    Did you try adding the Class-Path: entry to the manifest file?

    Main-Class: SettingsScreen
    Class-Path: <theJarFilesHere>
    If you don't understand my response, don't ignore it, ask a question.

Similar Threads

  1. Replies: 5
    Last Post: 03-17-2011, 02:26 PM
  2. Replies: 8
    Last Post: 11-04-2010, 01:46 PM
  3. Replies: 5
    Last Post: 06-02-2010, 01:05 PM
  4. Replies: 3
    Last Post: 06-01-2010, 03:01 PM
  5. Replies: 2
    Last Post: 09-18-2008, 07:30 AM

Posting Permissions

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