我的 Java 项目有许多依赖项,例如,Box2d
我在我的 中定义
了以下 s 列表,因此使用 Maven 来管理项目。
注意:我在底部列出了依赖项,但不包括在此处。OpenGl
OpenAl
plugin
pom.xml
pom.xml
我按照这个文档开始:http ://maven.apache.org/plugins/maven-shade-plugin/examples/executable-jar.html
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source/>
<target/>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.3</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>com.app.game.Main</mainClass>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
当我运行时mvn package
,jar
会创建 a ,即target/test-0.1.jar
它实际上包含所有jar
依赖项,并在包的根目录中包含本机.so
和库。.dll
但是当我尝试从 CLI 运行应用程序时,我得到了UnsatisfiedLinkError
异常。
我错过了什么pom
吗?
[rob@work target]$ java -jar test-0.1.jar
log4j:WARN No appenders could be found for logger (com.app.game.Main).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
Catched FileNotFoundException: /home/rob/git/test/target/test-0.1-natives-linux-amd64.jar (No such file or directory), while addNativeJarLibsImpl(classFromJavaJar class com.jogamp.common.os.Platform, classJarURI jar:file:/home/rob/git/test/target/test-0.1.jar!/com/jogamp/common/os/Platform.class, nativeJarBaseName test-0.1-natives-linux-amd64.jar): [ file:/home/rob/git/test/target/test-0.1.jar -> file:/home/rob/git/test/target/ ] + test-0.1-natives-linux-amd64.jar -> slim: jar:file:/home/rob/git/test/target/test-0.1-natives-linux-amd64.jar!/
Exception in thread "main" java.lang.UnsatisfiedLinkError: /home/rob/git/test/target/libgluegen-rt.so (/home/rob/git/test/target/liblibgluegen-rt.so.so: cannot open shared object file: No such file or directory)
at java.lang.ClassLoader.loadLibraryWithPath(ClassLoader.java:1217)