儘管我的應用程序可以在Eclipse中正常工作,但在使用Maven着色插件和'運行JAR時,我得到一個異常,說明無法找到所需的JOGL二進制庫當前工作目錄,因爲它不在當前工作目錄中,而是在JAR本身的根目錄中。錯誤的庫路徑從Maven執行時着色.jar
Exception in thread "main" java.lang.UnsatisfiedLinkError: Can't load library: /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:
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的本地庫解壓縮。這是增加的「linux-amd64來我的JAR的名稱的末尾,認爲這是JOGL,只有庫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)
那麼,據我所知,不可能從JAR直接使用本地庫,它必須被提取到文件系統中目標系統並從那裏加載。這裏有maven-nar-plugin,旨在簡化包裝 – user3159253
你是對的;我完全忘了。它開始看起來像JOGL不會將庫卸載到temp或臨時位置未被添加到lib路徑。 – user515655