使用java命令出现Error: A JNI error has occurred, please check your installation and try again的错误

使用java命令出现Error: A JNI error has occurred, please check your installation and try again的错误

暂发现有两种原因,仔细看后面的报错信息

1、jdk版本不匹配

在这里插入图片描述
Exception in thread “main” java.lang.UnsupportedClassVersionError: helloworld has been compiled by a more recent version of the Java Runtime (class file version 54.0), this version of the Java Runtime only recognizes class file versions up to 52.0

发现为java与javac版本不一致而造成的,更换为一致之后重新编译打包

2、Invalid signature file digest for Manifest main attributes–文件签名不合法

在这里插入图片描述
这是因为在使用Maven打包的时候导致某些包的重复引用,以至于打包之后的META-INF的目录下多出了一些*.SF,.DSA,.RSA文件所致
如果使用maven打包则可以在pom.xml加上如下配置

<build>
  <plugins>
  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-shade-plugin</artifactId>
    <version>2.2</version>
    <configuration>
      <filters>
        <filter>
          <artifact>*:*</artifact>
          <excludes>
            <exclude>META-INF/*.SF</exclude>
            <exclude>META-INF/*.DSA</exclude>
            <exclude>META-INF/*.RSA</exclude>
          </excludes>
        </filter>
      </filters>
    </configuration>
  </plugin>
  </plugins>
  </build>

如果用的是idea来打包 的
可以通过解压工具打开,删除META-INF的目录下的*.SF,.DSA,.RSA文件,即可
在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值