。jar文件和外部库

问题描述 投票:0回答:1

我有一个使用GraphStream(http://graphstream-project.org/)的图形项目。我似乎可以包含它,但是每当我尝试制作一个.jar文件时,就会出现Error: A JNI error has occurred, please check your installation and try again。我试图制作一个没有它的.jar文件,它看起来还不错,但是将其保存在其中至关重要,因为它在执行结束时绘制了一个图形。

GraphStream可能太旧而无法使用吗?有没有办法绕过这个?任何帮助,将不胜感激。我正在使用IntelliJ社区版本。

编辑:我曾尝试制作一个uber-jar(或fat-jar),但似乎出现了相同的错误。

java jar graphstream external-library
1个回答
0
投票

您可以尝试添加maven-assembly-plugin

  <build>
    <plugins>
      <plugin>
        <artifactId>maven-assembly-plugin</artifactId>
        <executions>
          <execution>
            <phase>package</phase>
            <goals>
              <goal>single</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
          <descriptorRefs>
            <descriptorRef>jar-with-dependencies</descriptorRef>
          </descriptorRefs>
        </configuration>
      </plugin>
    </plugins>
  </build>

这包括您在构建时在jar中的依赖项。

© www.soinside.com 2019 - 2024. All rights reserved.