javaxmlnetbeansjdom

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


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 :

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 ?


Solution

  • 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.