JAVA Command Error: A JNI error has occurred, please check your installation and try again [Solved]

Run Java program, javac run. Java file does not report an error, but when Java runs, it reports an error

Look at the error report carefully

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

Check the reason and find that it is caused by the inconsistency between Java and javac versions

Java – version and javac – version, if so

The two versions are inconsistent



1. How many Java versions are there in Linux system

rpm -qa |grep java

2. Then delete them one by one

rpm -e --nodeps java-1.8.0-openjdk-headless-
rpm -e --nodeps java-1.7.0-openjdk-
rpm -e --nodeps java-1.7.0-openjdk-headless-
rpm -e --nodeps java-1.8.0-openjdk- 
(type rpm -e --nodeps + "existing java version") Delete as many as you can

3. Check whether the original java version is removed completely

[root@yuan 8-1]# java - version
-bash: /usr/bin/java: No such file or directory

4. After the original version is removed, configure the newly installed Java environment variables

vi /etc/profile 

Edit the profile file and add

JAVA_HOME=/usr/local/java/jdk-10.0.2/   ###("jdk-10.0.2" to the installation file name of the version of java you want to install)
JRE_HOME=$JAVA_HOME/ ### (since there is no jre folder after jdk10 is unzipped, if it is for a version below jdk10 it should
                               for “JRE_HOME=$JAVA_HOME/jre”)

5. Last update

source /etc/profile


Similar Posts: