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
Solution:
1. Query how many Java versions are in Linux
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
Solution:
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-1.8.0.181-3.b13.el7_5.x86_64
rpm -e --nodeps java-1.7.0-openjdk-1.7.0.171-2.6.13.0.el7_4.x86_64
rpm -e --nodeps java-1.7.0-openjdk-headless-1.7.0.171-2.6.13.0.el7_4.x86_64
rpm -e --nodeps java-1.8.0-openjdk-1.8.0.181-3.b13.el7_5.x86_64
(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
for“JRE_HOME=$JAVA_HOME/jre”)
PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin:$PATH
CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib:$CLASSPATH
export JAVA_HOME JRE_HOME PATH CLASSPATH
5. Last update
source /etc/profile
complete
Read More:
- Spark-SQL Error: A JNI error has occurred, please check your installation and try again Exceptio
- [Solved] eclipse Error: Error:A JNI error has occurred, please check your installation and try again
- [Solved] An unexpected error has occurred. Conda has prepared the above report.
- Conda create New environment Error: An unexpected error has occurred. Conda has prepared the above report.
- Transaction check error during docker CE installation [How to Solve]
- [Solved] Faceswap Error: CRITICAL An unexpected crash has occurred.You MUST provide this file if seeking assistan
- Eclipse an error has occurred [How to Solve]
- [Solved] elasticsearch.bat Running Flashback.: Error occurred during initialization of VM, Error occurred during initializatio
- IIS 404 The page cannot be displayed because an internal server error has occurred
- [Solved] JNI Error: Fatal signal 11 (SIGSEGV)
- [Solved] Rancher Add User Error: x509: certificate has expired Internal error occurred: failed calling webhook “rancherauth.cattle.io”:
- [Solved] JNI DETECTED ERROR IN APPLICATION: GetStringUTFChars received NULL jstring
- Nacos Error: server is DOWN now, please try again later! [How to Solve]
- [Solved] ESP32 Error: error: expected initializer before ‘__result_use_check‘
- [Solved] Android7 8 Jack server SSL error: Jack server failed to (re)start, try ‘jack-diagnose’ or see Jack server log
- ERROR: JDWP Unable to get JNI 1.2 environment, jvm
- [Solved] NDK JNI DETECTED ERROR IN APPLICATION: use of deleted local reference
- [Solved] matlab error: try to write SCRIPT vl_sift is executed as a function
- [Solved] error TS2584: Cannot find name ‘console’. Do you need to change your target library? Try changing the ‘lib’ compiler option to include ‘dom’.
- [Solved] sparkSQL Error: WARN TaskMemoryManager: Failed to allocate a page (bytes), try again.