【问题标题】:java.lang.UnsatisfiedLinkError when using Maven imported libraries (Java3D)使用 Maven 导入库 (Java3D) 时出现 java.lang.UnsatisfiedLinkError
【发布时间】:2018-06-30 15:35:25
【问题描述】:

我一直在尝试在我的 Maven 项目中添加一些 Java 3D 依赖库,但我收到了“UnsatisfiedLinkError”。环顾四周后,我想我看到了这个错误,因为 java 在 java.libraries.home 中找不到一些必需的本机库(.dll?)。

我在网上看到了有关将我的机器 PATH 链接到 .dll 文件(并因此将它们添加到我的机器 java.library.home)的解决方案,但我正在寻求一种适用于任何 mvn 安装的解决方案。

让我感到困惑的是,我正在使用其他 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>

错误信息:

线程“主”java.lang.UnsatisfiedLinkError 中的异常:java.library.path 中没有 J3D 在 java.lang.ClassLoader.loadLibrary(ClassLoader.java:1867) 在 java.lang.Runtime.loadLibrary0(Runtime.java:870) 在 java.lang.System.loadLibrary(System.java:1122) 在 javax.media.j3d.MasterControl$22.run(MasterControl.java:889) 在 java.security.AccessController.doPrivileged(本机方法) 在 javax.media.j3d.MasterControl.loadLibraries(MasterControl.java:886) 在 javax.media.j3d.VirtualUniverse.(VirtualUniverse.java:229) 在 javax.media.j3d.Canvas3D.(Canvas3D.java:3533) 在 gfx.point_viewer.PointFrame.(PointFrame.java:50) 在 gfx.GUIManager.createPointFrame(GUIManager.java:81) 在 gfx.GUIManager.(GUIManager.java:59) 在graphsim.Simulator.start(Simulator.java:40) 在graphsim.Simulator.main(Simulator.java:125)

【问题讨论】:

    标签: java maven import


    【解决方案1】:

    显然我使用的 Java3D 库对于 Maven 等构建工具来说“太旧”了,这意味着包装库被放在我的 .m2 目录中,但没有任何功能被链接。

    容易修复;使用不同的库。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-05-07
      • 2013-02-10
      • 2021-11-25
      • 2015-02-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多