简体   繁体   中英

Java classpath NoClassDefFoundError

I am trying to run testjar.jar , that depends on ConnectionException class residing in wsc-22.jar

Both jar is in the same folder.

What's wrong with bellow command..? (It is working well in Eclipse, i just exported into testjar.jar)

Thank you ..

lib > java -cp ./wsc-22.jar  -jar testjar.jar 
Exception in thread "main" java.lang.NoClassDefFoundError: com/sforce/ws/ConnectionException
Caused by: java.lang.ClassNotFoundException: com.sforce.ws.ConnectionException

You cannot use -cp (nor -classpath) along with -jar

do java -cp ./wsc-22.jar;testjar.jar my.package.Main

substitute the above accordingly

Another option is to add wsc-22.jar in the testjar.jar manifest file.

For instance in testjar.jar:

MANIFEST.MF

Manifest-Version: 1.0  
Main-Class: my.path.to.the.main.Application  
Class-Path: wsc-22.jar

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM