I have download a xSocket.jar which will be use as a classpath and compile myprogram.jar, both are in Java folder. Is adding a classpath in Manifest able to find xSocket.jar without the need to define a -cp
in commandline?
In my commandline D:\\>
location, I tried running java -jar java\\myprogram.jar -n 0
Exception in thread "main" java.lang.NoClassDefFoundError: org/xsocket/connectio
n/IBlockingConnection
at myprogram.main(myprogram.java:114)
Caused by: java.lang.ClassNotFoundException: org.xsocket.connection.IBlockingCon
nection
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
... 1 more
My Manifest in myprogram.jar:
Manifest-Version: 1.0
Created-By: 1.6.0_22 (Sun Microsystems Inc.)
Main-Class: myprogram
Class-Path: xSocket
You need to specify the full jar file name ie with extension. Check here for more information.
Class-Path: xSocket.jar
Is adding a classpath in Manifest able to find xSocket.jar without the need to define a -cp in commandline?
Yes, it's the way.
You should change your class pass value in myprogram.jar
to
Class-Path: relatedPath/xSocket.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.