linux - unix java classpath cp adding -
this seemingly simple problem stumping me. have jar set of dependencies cannot seem working in linux. jars , script reside in same directory.
this 1 picks , tries run main class
java -cp myjar.jar com.mylib.mymainclass
but of course throws classnotfoundexception
on 1 of dependency classes. try add 1 of dependencies so
java -cp myjar.jar:mydependencyjar.jar com.mylib.mymainclass
then says classnotfoundexception
com.mylib.mymainclass
!
i tried these various same problems
java -cp . com.mylib.mymainclass
and this
java -cp *.jar com.mylib.mymainclass
and this
java -cp .:*.jar com.mylib.mymainclass
any idea please ?
try one:
java -cp /path/to/jar1.jar:/path/to/jar2.jar:. com.mylib.mymainclass
note should not omit final .
in classpath, represent current working directory, because using -cp
override previous classpath setting.
Comments
Post a Comment