This problem is caused by a Java class file compiled by a higher version of JDK trying to run on a lower version of JVM.
1. The solution is to ensure that the versions of JVM (Java command) and JDK (javac command) are consistent. If it is the Linux version, enter the Java – version and javac – version commands in the command line to see if the versions are consistent. I use 1.7.0_ 80。
2. The same version still can’t solve the problem. I don’t compile with javac directly from the command line, but with eclipse compiler. Because many compilers come with javac, rather than using the compiler in the operating system. If your compiler is eclipse, you need to set the JDK version in the properties of the project. The method is to right-click the project — & gt; properties — & gt; Java compiler — & gt; enable project specific settings — & gt; and set the compiler compliance level to 1.7, which is the version consistent with the JVM (the version shown by Java – version in the command line). Because of the need to be compatible with other software before, I reduced the Java version from 1.8 to 1.7, but eclipse did not move, so after opening it, I found that the default was 1.8, so I manually reduced it to 1.7, recompiled it, and finally passed!
To sum up, if you are compiling with a compiler, make sure that the JDK version of the compiler is consistent with the Java version of the operating system.
The screenshot is as follows:
- Eclipse .java File Syntax error, parameterized types are only available if source level is 1.5 or
- Error: could not find java.dll Error: could not find Java se runtime environment solution
- @Solution to override error
- The solution of multiple markers at this line @ override
- Start Eclipse and pop up the “Failed to load the JNI shared library jvm.dll” dialog box
- Syntax error, annotations are only available if source level is 1.5 or greater.
- Java was started but returned exit code = 13 problem solving
- A JNI error has occurred, please check your installation and try again
- Error: opening registry key ‘Software\JavaSoft\Java Runtime Environment’
- Failed to load the JNI shared library solution
- Access restriction in Eclipse: the type ‘xxx’ is not API solution
- Eclipse report error Error:opening registry key ‘Software/JavaSoft/JRE’
- Successful solution of eclipse startup error Error:Could not create the Java Virtual Machine Error:A fatal exception has occurred
- Eclipse Syntax error, annotations are only available if source level is 1.5 or greater
- Syntax error, insert “Finally” to complete TryStatem in Myeclipse in Java-
- Error: (44,73) lambda expression and XML are not supported in Java: – source 1.7 Error:java : Compilation failed
- Java learning error information 3 — Java notes
- Eclipse can’t open an error: Error:could not find java SE Runtime Environment/Error: could not find java.dll
- eclipse cdt Program “make” not found in PATH
- Solve the Java “syntax error on token enum” problem