gpt4 book ai didi

java - 从 Maven 阴影 .jar 执行时库路径错误

转载 作者:搜寻专家 更新时间:2023-11-01 03:38:25 25 4
gpt4 key购买 nike

尽管我的应用程序在 Eclipse 中运行良好,但当使用 Maven 着色插件并“运行”JAR 时,我得到一个异常,说明无法在当前工作目录中找到所需的 JOGL 二进制库,这是正确的,因为它不在当前工作目录,但在 JAR 本身的根目录中。

线程“main”中的异常 java.lang.UnsatisfiedLinkError:无法加载库:/path/to/working/dir/libgluegen-rt.so

我已确认该文件按预期存在于 JAR 的根目录中。

我的 POM 的插件调用:

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<shadedArtifactAttached>true</shadedArtifactAttached>
<shadedClassifierName>RunMe</shadedClassifierName>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>path.confirmed.to.work.RunMe</mainClass>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>

我的 JAR list :

Manifest-Version: 1.0
Build-Jdk: 1.6.0_30
Built-By: me
Created-By: Apache Maven
Main-Class: path.confirmed.to.work.RunMe
Archiver-Version: Plexus Archiver

想法?有什么建议吗?

更新:看起来阴影插件混淆了 JOGL 的本地库解包。它在我的 jar 名称的末尾添加了“linux-amd64,认为这是 JOGL-only 库 jar!

Catched FileNotFoundException: /path/to/my/git/project/target/0.0.1-SNAPSHOT-RunMe-natives-linux-amd64.jar (No such file or directory), while TempJarCache.bootstrapNativeLib() of jar:file:/path/to/my/git/project/terminal-recall/target/trcl-0.0.1-SNAPSHOT-RunMe-natives-linux-amd64.jar!/ (file:/path/to/my/git/project/target/ + trcl-0.0.1-SNAPSHOT-RunMe-natives-linux-amd64.jar)

最佳答案

JOGL native 库加载记录在此处:
https://jogamp.org/wiki/index.php/JogAmp_JAR_File_Handling

通过 maven shade-plugin 工作来获得单体/Fat-Jar 的一种简单方法是从 lib 文件夹中提取 native 库(例如从 http://jogamp.org/deployment/jogamp-current/archive/jogamp-all-platforms.7z )并将它们放入您的 Maven 项目的 src/main/resources/natives 文件夹中。这样,这些库最终会位于 Fat-Jar 的 natives 子文件夹中 as described

关于java - 从 Maven 阴影 .jar 执行时库路径错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22213948/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com