I read XML documents (JDOM), and I get an exception java.lang.NoClassDefFoundError when running it on another PC

Cruxial :

This is my first java software... The software works well on my dev machine, but I get that exception on the other (non-dev) machine (both on Windows 10) : java.lang.NoClassDefFoundError: org/jdom2/JDOMException

I read that there is something related with the JDOM versions, and that the key should be something with the xerces.jar order in the classpath (www.jdom.org)... I tried different approaches, without any result.

I work with NetBeans, and it is not clear for me how to include JDOM. What I did :

  • Under Tools, Libraries, I created a JDOM library, and included in it jdom-2.0.6.jar, and also added then xercesImpl.jar, and also xml-apis.jar, and checked that xerces comes first: JDOM library creation
  • Then, I use Add Library... by right-clicking on the Library folder of my project: Add Library

The software works well on my development PC... but then I this exception when creating my XML object, on another PC (which has no development environment) :

Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: org/jdom2/JDOMException

What am I doing wrong ?

djharten :

You said you have no development environment on the other PC, so if you don't have the JARs available then running the program won't work because you don't have the dependencies installed.

I would recommend looking into Maven. It's a package manager(among other things), and can help you with this sort of thing. Here is a link to Maven's main page. The library you're looking for is here. Read the tutorials for how to set up a Maven project and add dependencies to the pom.xml file.

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=415181&siteId=1