目前,我收到有关如何找不到我的包含之一的错误,特别是
java.lang.ClassNotFoundException: org.jivesoftware.smack.provider.ProviderManager
我已经确认该文件作为可执行 jar 运行,所以我真的不知道为什么会出现这样的错误,有人可以提供一些见解吗?
这是我目前正在做的事情,如果其中任何步骤有误,请纠正我。
我带着我的(确认工作的)程序,运行它来仔细检查。
我右键单击项目 > 导出 > 可运行 jar 文件并选择选项 > 将所需库打包到生成的 jar 文件中,然后将 Ant Build 脚本导出到文件 myProg.xml
当 myprog.xml 出来时,它看起来像这样:
<?xml version="1.0" encoding="UTF-8" standalone="no"?> <project default="create_run_jar" name="Create Runnable Jar for Project myProg with Jar-in-Jar Loader"> <!--this file was created by Eclipse Runnable JAR Export Wizard--> <!--ANT 1.7 is required --> <target name="create_run_jar"> <jar destfile="C:/Users/Dbell/Documents/EclipseProjects/myProg/myProg.jar"> <manifest> <attribute name="Main-Class" value="org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader"/> <attribute name="Rsrc-Main-Class" value="com.myCom.noc.xmpptroubleshooter.Main"/> <attribute name="Class-Path" value="."/> <attribute name="Rsrc-Class-Path" value="./ httpasyncclient-4.0-beta2.jar httpcore-4.2.1.jar httpcore-nio-4.2.1.jar httpclient-4.2.1.jar commons-logging-1.1.1.jar commons-codec-1.6.jar log4j-1.2.12.jar logkit-1.0.1.jar avalon-framework-4.1.3.jar servlet-api-2.3.jar commons-net-3.1.jar xpp3_min-1.1.4c.jar NocLib-1.1.jar smack32-3.2.0.jar httpclient-3.1.jar"/> </manifest> <zipfileset src="jar-in-jar-loader.zip"/> <fileset dir="C:/Users/Dbell/Documents/EclipseProjects/myProg/bin"/> <zipfileset dir="C:\Users\Dbell\.ivy2\cache\org.apache.httpcomponents\httpasyncclient\jars" includes="httpasyncclient-4.0-beta2.jar"/> <zipfileset dir="C:\Users\Dbell\.ivy2\cache\org.apache.httpcomponents\httpcore\jars" includes="httpcore-4.2.1.jar"/> <zipfileset dir="C:\Users\Dbell\.ivy2\cache\org.apache.httpcomponents\httpcore-nio\jars" includes="httpcore-nio-4.2.1.jar"/> <zipfileset dir="C:\Users\Dbell\.ivy2\cache\org.apache.httpcomponents\httpclient\jars" includes="httpclient-4.2.1.jar"/> <zipfileset dir="C:\Users\Dbell\.ivy2\cache\commons-logging\commons-logging\jars" includes="commons-logging-1.1.1.jar"/> <zipfileset dir="C:\Users\Dbell\.ivy2\cache\commons-codec\commons-codec\jars" includes="commons-codec-1.6.jar"/> <zipfileset dir="C:\Users\Dbell\.ivy2\cache\log4j\log4j\jars" includes="log4j-1.2.12.jar"/> <zipfileset dir="C:\Users\Dbell\.ivy2\cache\logkit\logkit\jars" includes="logkit-1.0.1.jar"/> <zipfileset dir="C:\Users\Dbell\.ivy2\cache\avalon-framework\avalon-framework\jars" includes="avalon-framework-4.1.3.jar"/> <zipfileset dir="C:\Users\Dbell\.ivy2\cache\javax.servlet\servlet-api\jars" includes="servlet-api-2.3.jar"/> <zipfileset dir="C:\Users\Dbell\.ivy2\cache\commons-net\commons-net\jars" includes="commons-net-3.1.jar"/> <zipfileset dir="C:\Users\Dbell\.ivy2\cache\xpp3\xpp3_min\jars" includes="xpp3_min-1.1.4c.jar"/> <zipfileset dir="C:\Users\Dbell\.ivy2\cache\com.MyCom\NocLib\jars" includes="NocLib-1.1.jar"/> <zipfileset dir="C:\Users\Dbell\.ivy2\cache\com.MyCom\smack32\jars" includes="smack32-3.2.0.jar"/> <zipfileset dir="C:\Users\Dbell\.ivy2\cache\com.apache\httpclient\jars" includes="httpclient-3.1.jar"/> </jar> <signjar jar="myProg.jar" alias="myAlias" keystore="path/to/myKs.ks" storepass="MyPass"/> </target> </project>
从那里我右键单击>运行为> ant构建文件来签署我的jar。
然后我将它移动到我的网络服务器,其中存在一个 launch.jnlp 文件。看起来像这样:
<?xml version="1.0" encoding="UTF-8" standalone="no"?> <jnlp codebase="http://myServer:8080/myProg/" href="http://myServer:8080/myProg/launch.jnlp" spec="6.0+"> <information> <title>myProg</title> <vendor>myName</vendor> <homepage href="http://myServer:8080/myProg/"/> <description>myProg</description> <description kind="short">myProg</description> </information> <security> <all-permissions/> </security> <resources> <j2se version="1.6+" /> <jar href="myProg.jar" main="true"/> </resources> <application-desc main-class="com.myCom.noc.pathToMain.Main"> </application-desc> </jnlp>
启动应用程序时的完整堆栈跟踪:
java.lang.ClassNotFoundException: org.jivesoftware.smack.provider.ProviderManager
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at com.sun.jnlp.JNLPClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at com.myCom.noc.xmpptroubleshooter.Main.main(Main.java:83)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.sun.javaws.Launcher.executeApplication(Unknown Source)
at com.sun.javaws.Launcher.executeMainClass(Unknown Source)
at com.sun.javaws.Launcher.doLaunchApp(Unknown Source)
at com.sun.javaws.Launcher.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
这是我的罐子里面