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. :(blush):
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.
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.
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.
Re: java.lang.noClassDefFoundException using JDom2
Quote:
Originally Posted by
Norm
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?
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.
Re: java.lang.noClassDefFoundException using JDom2
Quote:
Originally Posted by
Norm
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.
Re: java.lang.noClassDefFoundException using JDom2
Did you try adding the Class-Path: entry to the manifest file?
Main-Class: SettingsScreen
Class-Path: <theJarFilesHere>