我试图从this project构建单个jar以在其他计算机上运行。
我尝试从命令行构建它:
clustertag/out/production/ClusterTag$ jar cmvf META-INF/MANIFEST.MF app.jar no/simula/clustertag/*.class
added manifest
adding: no/simula/clustertag/Engine$10.class(in = 1525) (out= 825)(deflated 45%)
adding: no/simula/clustertag/Engine$1.class(in = 9190) (out= 5067)(deflated 44%)
adding: no/simula/clustertag/Engine$1MyDouble.class(in = 610) (out= 380)(deflated 37%)
adding: no/simula/clustertag/Engine$2.class(in = 1397) (out= 670)(deflated 52%)
adding: no/simula/clustertag/Engine$3.class(in = 1530) (out= 704)(deflated 53%)
adding: no/simula/clustertag/Engine$4.class(in = 1883) (out= 888)(deflated 52%)
adding: no/simula/clustertag/Engine$5.class(in = 3121) (out= 1477)(deflated 52%)
adding: no/simula/clustertag/Engine$6.class(in = 1619) (out= 782)(deflated 51%)
adding: no/simula/clustertag/Engine$7.class(in = 1820) (out= 798)(deflated 56%)
adding: no/simula/clustertag/Engine$8.class(in = 2083) (out= 1082)(deflated 48%)
adding: no/simula/clustertag/Engine$9.class(in = 2656) (out= 1351)(deflated 49%)
adding: no/simula/clustertag/Engine.class(in = 20223) (out= 9992)(deflated 50%)
adding: no/simula/clustertag/Features.class(in = 7814) (out= 3650)(deflated 53%)
adding: no/simula/clustertag/Features$GlobalFeatureInfo.class(in = 1009) (out= 511)(deflated 49%)
adding: no/simula/clustertag/Frame.class(in = 7590) (out= 2358)(deflated 68%)
adding: no/simula/clustertag/ImageInternal.class(in = 929) (out= 455)(deflated 51%)
adding: no/simula/clustertag/Main$1.class(in = 1791) (out= 792)(deflated 55%)
adding: no/simula/clustertag/Main$2.class(in = 2347) (out= 1341)(deflated 42%)
adding: no/simula/clustertag/Main$3.class(in = 529) (out= 339)(deflated 35%)
adding: no/simula/clustertag/Main.class(in = 11513) (out= 5778)(deflated 49%)
adding: no/simula/clustertag/ObjectPos.class(in = 1096) (out= 520)(deflated 52%)
adding: no/simula/clustertag/Objects.class(in = 6123) (out= 3108)(deflated 49%)
adding: no/simula/clustertag/PictureInternal.class(in = 2765) (out= 1007)(deflated 63%)
adding: no/simula/clustertag/Thumb.class(in = 1763) (out= 739)(deflated 58%)
adding: no/simula/clustertag/Tree.class(in = 6786) (out= 2500)(deflated 63%)
adding: no/simula/clustertag/TreeNode.class(in = 4858) (out= 2050)(deflated 57%)
adding: no/simula/clustertag/TreeProcessor.class(in = 732) (out= 342)(deflated 53%)
adding: no/simula/clustertag/TreeView.class(in = 3838) (out= 1759)(deflated 54%)
adding: no/simula/clustertag/TreeView$MyTreeModelListener.class(in = 1916) (out= 891)(deflated 53%)
但是当我尝试运行它时,我收到错误:
java -jar app.jar
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.NoClassDefFoundError: org/newdawn/slick/Game
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
at java.lang.Class.privateGetMethodRecursive(Class.java:3048)
at java.lang.Class.getMethod0(Class.java:3018)
at java.lang.Class.getMethod(Class.java:1784)
at sun.launcher.LauncherHelper.validateMainClass(LauncherHelper.java:544)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:526)
Caused by: java.lang.ClassNotFoundException: org.newdawn.slick.Game
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 7 more
此外,我尝试在Intellij Idea中将其构建为工件,但也会出错:
clustertag/out/artifacts/ClusterTag_jar$ java -jar ClusterTag.jar
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.SecurityException: Invalid signature file digest for Manifest main attributes
at sun.security.util.SignatureFileVerifier.processImpl(SignatureFileVerifier.java:330)
at sun.security.util.SignatureFileVerifier.process(SignatureFileVerifier.java:263)
at java.util.jar.JarVerifier.processEntry(JarVerifier.java:318)
at java.util.jar.JarVerifier.update(JarVerifier.java:230)
at java.util.jar.JarFile.initializeVerifier(JarFile.java:383)
at java.util.jar.JarFile.getInputStream(JarFile.java:450)
at sun.misc.URLClassPath$JarLoader$2.getInputStream(URLClassPath.java:977)
at sun.misc.Resource.cachedInputStream(Resource.java:77)
at sun.misc.Resource.getByteBuffer(Resource.java:160)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:454)
at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:495)
在libbin
文件夹项目中有一些.so
dependensies,那么可能会导致问题?
答案 0 :(得分:0)
最后我从命令行解决了它:
jar cmvf META-INF/MANIFEST.MF app.jar no/simula/clustertag/*.class
在META-INF/MANIFEST.MF
中我添加了libs:
Manifest-Version: 1.0
Main-Class: no.simula.clustertag.Main
Class-Path: lib/ibxm.jar lib/jinput.jar lib/jnlp.jar lib/jogg-0.0.7.jar lib/jorbis-0.0.15.jar lib/lire.jar lib/lwjgl.jar lib/lwjgl_util.jar lib/lwjgl_util_applet.jar lib/natives-linux.jar lib/slick.jar lib/tinylinepp.jar
并通过java -Djava.library.path=libbin -jar app.jar