ここにシェルスクリプトがあります:
#!/bin/sh
cd ../../../lib
ls
MY_LIB=`pwd`
for jar in `ls $MY_LIB/*.jar`
do
CLASSPATH="$CLASSPATH:""$jar"
done
echo $CLASSPATH
cd ..
#java -jar build/libs/myproject.jar -classpath \"$CLASSPATH\"
このスクリプトを実行すると、次のように出力されます。
commons-codec-1.6.jar httpclient-4.2.1.jar httpcore-4.2.1.jar logback-classic-1.0.6.jar slf4j-api-1.6.0.jar
commons-logging-1.1.1.jar httpclient-cache-4.2.1.jar httpmime-4.2.1.jar logback-core-1.0.6.jar
:/home/user/mygitproject/myproject/lib/commons-codec-1.6.jar:/home/user/mygitproject/myproject/lib/commons-logging-1.1.1.jar:/home/user/mygitproject/myproject/lib/httpclient-4.2.1.jar:/home/user/mygitproject/myproject/lib/httpclient-cache-4.2.1.jar:/home/user/mygitproject/myproject/lib/httpcore-4.2.1.jar:/home/user/mygitproject/myproject/lib/httpmime-4.2.1.jar:/home/user/mygitproject/myproject/lib/logback-classic-1.0.6.jar:/home/user/mygitproject/myproject/lib/logback-core-1.0.6.jar:/home/user/mygitproject/myproject/lib/slf4j-api-1.6.0.jar
Exception in thread "main" java.lang.NoClassDefFoundError: ch/qos/logback/core/joran/spi/JoranException
at com.test.MainTest.main(MainTest.java:223)
Caused by: java.lang.ClassNotFoundException: ch.qos.logback.core.joran.spi.JoranException
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
... 1 more
なぜ例外が発生するのですか?
クラスパスが間違っていますか?
java -classpath の使用は間違っていますか?