I read an XML document (JDOM) and I get an exception java.lang.NoClassDefFoundError when running on another PC
This is my first Java software…
The software works fine on my dev machine, but I get an exception on another (non-dev) machine (both on Windows 10): java.lang.NoClassDefFoundError: org/jdom2/JDOMException/
p>
I’ve read that there is something related to the JDOM version, and the key should be something in the xerces.jar order in the classpath (www.jdom.org)… I tried different methods but nothing came of it.
I
use NetBeans and I don’t know how to include JDOM.
What I did :
- Under
Tools
,Libraries
, I created a JDOM library and included it injdom-2.0.6
.jar, along withxercesImpl.jar,
andxml-apis.jar
, and checked Whether xerces comes first: JDOM library creation - Then, I use Add Library… to right-click on my project’s Library folder:
Add Library
The software works fine on my development PC… But I get this exception when I create my XML object on another PC (no development environment:
).
Exception java.lang.NoClassDefFoundError: org/jdom2/JDOMException in thread 'AWT-EventQueue-0'
What am I doing wrong?
Solution
You say you don’t have a development environment on another computer, so if you don’t have a JAR available, then running the program won’t work because you don’t have dependencies installed.
I recommend looking into Maven. It’s a package manager (among other things) that can help you with this sort of thing. Here is a link to the Maven homepage. The library you’re looking for is here.xml.