Hi all,

isn't that what the Eclipse *Export Wizard*...
"Runnable JAR File"
with the option
"Package required libraries into generated JAR"
...does?

It includes a "jarinjarloader" in the JAR.

All the best,
DaveLaw



On 11/02/2018 12:17, Nick Burch wrote:
On Sat, 10 Feb 2018, Marco Lechner - FOSSGIS e.V. wrote:
Exception in thread "main" java.lang.NoClassDefFoundError:
org/apache/poi/xwpf/usermodel/XWPFDocument
    at de.bfs.dokpool.faq.importer.FaqImporter.main(FaqImporter.java:23)
Caused by: java.lang.ClassNotFoundException:
org.apache.poi.xwpf.usermodel.XWPFDocument

The as far as I know relevant dependency packages seem to be included in
the jar-file. Tried with unzip -l:

$ unzip -l target/dokpool-faq-importer.jar
Archive:  target/dokpool-faq-importer.jar
  Length      Date    Time    Name
---------  ---------- -----   ----
*snip*
   190432  2018-02-09 22:18 lib/gson-2.2.4.jar
   751238  2018-02-09 22:18   lib/commons-collections4-4.1.jar
    26514  2018-02-09 22:18   lib/stax-api-1.0.1.jar
  1433719  2018-02-09 22:18   lib/poi-ooxml-3.16.jar

Generally classloaders will only load classes from within a jar, not jars-within-jars.

If you want to only have a single jar with everything in, you'll either need to switch to a more "war-like" classloader to have jars within your jar loaded, or use something like shading/shadowing when you build the jar to have the classes of the dependencies in-lined within your jar

Nick


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@poi.apache.org
For additional commands, e-mail: user-h...@poi.apache.org

Reply via email to