Error: a JNI error has occurred, please check your installation and try again

Java files do not report an error, but Java does report an error when it is run
Take a closer look at the error message
Exception in thread “main” java.lang.UnsupportedClassVersionError: The helloworld has had been compiled by a more recent version of the Java Runtime (class file version 54.0), and this version of the Java Runtime only recognizes the class file versions up to 52.0
Check the cause and find that the Java version is inconsistent with the JavAC version.
Java-version and Javac-Version, indeed
The two versions do not agree
1. Query how many Java versions are in Linux

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- 
(Enter rpm --e --nodeps + "existing version of java") Delete as many as you can.

3. Verify that all the original Java versions have been removed

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

4. Configure newly installed Java environment variables after the original version is removed

vi /etc/profile 

Edit the profile file and add it at the end

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

5. Last update

source /etc/profile


Read More: