I use SLF4J logger. jar
file is placed in ../lib
directory. Application was created using maven and in Netbeans. But I want to do all by myself to teach myself.
Application is compiled with command (of course there are no spaces after semicolons - I added them for better readability):
javac -cp ../lib/poi-3.10-FINAL-20140208.jar;
../lib/slf4j-api-1.7.6.jar;
../lib/slf4j-log4j12-1.7.6.jar;
../lib/commons-io-1.4.jar
-d target/classes src\main\java\pl\alden\convertcosts\*.java
and I can run it with
java -cp ../lib/poi-3.10-FINAL-20140208.jar;
../lib/slf4j-api-1.7.6.jar;
../lib/slf4j-log4j12-1.7.6.jar;
../lib/commons-io-1.4.jar;
../lib/log4j-1.2.17.jar;
target/classes
pl/alden/convertcosts/App
I know I can set all jar files as clclasspath
system variable (Windows 7).
I want to put all into jar
and run it from this jar
. To create jar
I use
jar cvfm convertcosts.jar manifest.mf -C target/classes/ .
And I have proper jar
: jar tf convertcosts.jar
gives
META-INF/
META-INF/MANIFEST.MF
.netbeans_automatic_build
log4j.properties
pl/
pl/alden/
pl/alden/convertcosts/
pl/alden/convertcosts/App.class
pl/alden/convertcosts/ConvertCostsException.class
...
Now I want to run application from bat
file:
set classpath=../lib/poi-3.10-FINAL-20140208.jar;
../lib/slf4j-api-1.7.6.jar;
../lib/slf4j-log4j12-1.7.6.jar;
../lib/commons-io-1.4.jar;
../lib/log4j-1.2.17.jar
java -jar convertcosts.jar
As a result I have
Exception in thread "main" java.lang.NoClassDefFoundError:
org/slf4j/LoggerFactory
at pl.alden.convertcosts.App.<clinit>(App.java:10)
To me it looks like main jar
file does not see library jar
files.
What should I change?