I have a java application with many referenced libraries -(Apache POI some of them ) which I include in my build path.
All those libraries at my lib folder.
This code working correctly as expected from eclipse.
But it doesn't work when I have extracted jar file and try to run it from command line.
It throws below exception
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/poi/ss/use
This issue here that while I run the jar it doesn't see my libraries
Below my Jar where ReadExcelFileExample.class is the main class
I googled this issue and I tried the following and no one worked still give me the same exception :
1- Generate the MANIFEST while generating my jar to contains all the lib
2- java -cp ApplicationTest7.jar MyMainClass
3- java -cp "ApplicationTest7.jar;lib/*.jar" MyMainClass
4- java -cp "ApplicationTest7.jar;/lib/*;" MyMainClass
If you are creating JAR in Eclipse, then it has 3 options when you select Runable jar
1. Extract required libs into JAR
2. Package required libs into JAR
3. Copy required libs into a sub-folder next to JAR
So if you are selecting 2nd/3rd option there should not be any issue.
In 2nd option POI JARs will be inside your generated JAR and accordingly entries will be done in MANIFEST.MF by eclipse.
In 3rd option POI JARs will be put in a folder parallel to your generated JAR and accordingly classpath entries will be done in MANIFEST.MF by eclipse.
Can you tell the steps you are following in Eclipse to create the JAR?
posted 5 years ago
Find the three steps below .
What ever default MANIFEST or creating my own MANIFEST