我一直试图在我的Maven项目中添加一些Java 3D依赖库,但是却出现了“ UnsatisfiedLinkError”。经过一番环顾后,我认为我看到了此错误,因为Java无法在java.libraries.home中找到某些必需的本机库(.dll?)。
我已经看到了有关将我的机器PATH链接到.dll文件(因此将它们添加到我的机器java.library.home)的在线解决方案,但是我正在寻找一种适用于任何mvn安装的解决方案。 / p>
让我感到困惑的是,我正在使用其他Maven导入的库(JGraphT),它们可以正常工作。
有人知道在maven安装中自动添加本机库的方法吗?如果没有,可以尝试其他解决方案吗?
谢谢。
在我的pom.xml中:
<!-- language: lang-xml -->
<build>
<defaultGoal>clean install</defaultGoal>
<sourceDirectory>src</sourceDirectory>
<resources>
<resource>
<directory>res</directory>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</resource>
</resources>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
<configuration>
<archive>
<manifest>
<mainClass>graphsim.Simulator</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<!-- https://mvnrepository.com/artifact/java3d/j3d-core -->
<dependency>
<groupId>java3d</groupId>
<artifactId>j3d-core</artifactId>
<version>1.3.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/java3d/j3d-core-utils -->
<dependency>
<groupId>java3d</groupId>
<artifactId>j3d-core-utils</artifactId>
<version>1.3.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/java3d/vecmath -->
<dependency>
<groupId>java3d</groupId>
<artifactId>vecmath</artifactId>
<version>1.3.1</version>
</dependency>
</dependencies>
错误消息:
Exception in thread "main" java.lang.UnsatisfiedLinkError: no J3D in java.library.path at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1867) at java.lang.Runtime.loadLibrary0(Runtime.java:870) at java.lang.System.loadLibrary(System.java:1122) at javax.media.j3d.MasterControl$22.run(MasterControl.java:889) at java.security.AccessController.doPrivileged(Native Method) at javax.media.j3d.MasterControl.loadLibraries(MasterControl.java:886) at javax.media.j3d.VirtualUniverse.(VirtualUniverse.java:229) at javax.media.j3d.Canvas3D.(Canvas3D.java:3533) at gfx.point_viewer.PointFrame.(PointFrame.java:50) at gfx.GUIManager.createPointFrame(GUIManager.java:81) at gfx.GUIManager.(GUIManager.java:59) at graphsim.Simulator.start(Simulator.java:40) at graphsim.Simulator.main(Simulator.java:125)
答案 0 :(得分:0)
显然,我使用的Java3D库对于Maven这样的构建工具来说“太旧了”,这意味着包装器库已放置在我的.m2目录中,但没有任何功能被链接。
易于修复;使用其他库。