我使用這個命令來運行我的jar文件Jar文件執行問題?
java -cp otpreq.jar com.otp.req.SendRequest
及其給無差錯:
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/httpclient/methods/RequestEntity
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Unknown Source)
at java.lang.Class.privateGetMethodRecursive(Unknown Source)
at java.lang.Class.getMethod0(Unknown Source)
at java.lang.Class.getMethod(Unknown Source)
at sun.launcher.LauncherHelper.validateMainClass(Unknown Source)
at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.httpclient.methods.RequestEntity
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 7 more
爲什麼這個錯誤就要我想不通。
我檢查了庫和org/apache/commons/httpclient/methods/RequestEntity是一個接口。
我出口整個項目在Eclipse中JAR文件..這不是要所有的配套罐子綁定otpreq.jar – Mudit
@Mudit內,默認情況下,如果源被導出,IDE將綁定所有的jar。請檢查這些東西 - 1)otpreq.jar中的.classpath文件。 2)檢查是否從外部路徑添加了庫3)嘗試在命令行中給出類路徑(-cp)中的所有庫。 – Bhuvanwaitz