3

I've build the following jar (test.jar) with maven:

/META-INF
    MANIFEST.MF
/com
    /some classes

Here is the content of MANIFEST.MF:

Manifest-Version: 1.0
Archiver-Version: Plexus Archiver
Class-Path: lib/db2jcc.jar
Created-By: Apache Maven 3.3.9
Build-Jdk: 1.8.0_71
Main-Class: Main

As you can see I need a DB2 Driver to run my jar, so I put my librairies with the jar:

test.jar
/lib
    db2jcc.jar

I can run my executable with this command line:

java -cp "test.jar;lib/db2jcc.jar" Main

I would like to run it with the following ommand line:

java -jar test.jar

And the result is java.lang.NoClassDefFoundError: com/ibm/db2/jcc/DB2Driver. It looks like the lib folder is not read despite of my MANIFEST.MF. Does someone know what I am doing wrong?

Thanks in advance for your help.

Happy
  • 1,815
  • 2
  • 18
  • 33
  • Wouldn't be better to create a fat-jar with dependencies for your test code and execute it? so that dependencies would be embedded (easier to distribuite) and less error prone? a full example is [this Stack Overflow answer](http://stackoverflow.com/a/36047816/5606016) – A_Di-Matteo Jun 16 '16 at 13:32
  • Did you verify that the class is really in the db2jcc.jar? – Martin Baumgartner Jun 16 '16 at 13:42
  • @A.DiMatteo The point is this dependency is not a maven dependency so I need to add the jar manually. I tried a lot of different configurations to include and / or to exclude my dependency from the jar, none worked. – Happy Jun 16 '16 at 13:56
  • @MartinBaumgartner Yes it is. – Happy Jun 16 '16 at 13:56
  • Similar question https://stackoverflow.com/questions/60781244/manifest-mf-and-imports – Maria Ines Parnisari Mar 20 '20 at 20:32

0 Answers0