在 IntelliJ 中,我使用 Maven 为我的项目构建一个阴影 jar。我是 Maven 的新手,尽管我尽了最大努力,但可能还是做错了什么。
当我尝试运行 jar 时,出现以下错误:
A JNI error has occurred, please check your installation and try again
我检查了我的 java 版本,它应该在 JDK14 上运行
>java -version
openjdk version "14.0.1" 2020-04-14
OpenJDK Runtime Environment (build 14.0.1+7)
OpenJDK 64-Bit Server VM (build 14.0.1+7, mixed mode, sharing)
>javac -version
javac 14.0.1
我不确定我哪里出错了。任何帮助将不胜感激。如果您需要任何我没有提供的信息,请询问。由于我是 Maven 的新手,我不知道应该分享什么以及分享什么毫无意义。
此外,是否可以在每个用户不必升级到 Java 11 的情况下分发它?
这是我的 pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.thenorsepantheon</groupId>
<artifactId>wowslineupbuilder</artifactId>
<name>WoWs Lineup Builder</name>
<version>1.0-SNAPSHOT</version>
<properties>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
</properties>
<dependencies>
<!-- https://mvnrepository.com/artifact/com.google.guava/guava -->
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>28.2-jre</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.google.code.gson/gson -->
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.6</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.projectlombok/lombok -->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.12</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.3</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>com.thenorsepantheon.wowslineupbuilder.WoWsLineupBuilder</mainClass>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>11</source>
<target>11</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
最佳答案
我认为您的 Windows 机器上也安装了 java8 或 java9,并且您正在通过双击运行 jar。 Windows 正在使用旧版本的 java 启动您的 jar。 请尝试从命令行运行它以确保它是由 java14 启动的。喜欢
<jdk14-folder>\bin\java.exe -jar target\ -jar target\wowslineupbuilder-1.0-SNAPSHOT-shaded.jar
我建议您从计算机上卸载旧的 java。
关于你的第二个问题(分发给没有升级jdk11的用户)。你可能看过jlink这将允许您创建自定义 JDK(小的)并将其与您的 jar 一起分发。
关于java - IntelliJ + Maven Shade : A JNI error has occurred, 请检查您的安装并重试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61987991/
相关文章:
ethereum - 返回错误 : The method web3_clientVersion do
r - 在创建列表 tibble 列时在 "mutation"中使用 dplyr::sym() 会导
reactjs - React Rich Text Editor 真的可以在移动设备上运行吗?
docker - 如何处理 make missing from alpine docker imag
python - psutil.AccessDenied : psutil. AccessDenie
mongodb - mongoose 事务中创建集合的正确方法