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:
Read More:
- Successful solution of eclipse startup error Error:Could not create the Java Virtual Machine Error:A fatal exception has occurred
- Realize the simplest recursive call, simulate exception in thread “main” java.lang.stackoverflowerror exception
- Error: could not create the Java virtual machine Error:A Fatal exception has occurred
- [Solved] Mac ES Startup Error: Exception in thread “main“ java.nio.file.NotDirectoryException
- Error:Could not create the Java Virtical Machine. Error: A fatal exception has occurred. program
- Error: could not create the Java virtual machine. Error: a fatal exception has occurred
- Exception in thread “main“ java.lang.ClassCastException: com.sun.proxy.$Proxy8 cannot be cast to XXX
- [Solved] org.mongodb.driver.cluster – Exception in monitor thread while connecting to server node1:27017
- Eclipse:An error has occurred. See error log for more details. java.lang.NullPointerException
- Idea ignores compilation errors and runs in eclipse compilation mode
- Error: Exception was raised when calling per-thread-terminate function in extension lrwreplaymain.dl
- java.lang.IllegalStateException Exception: cause analysis and solution
- Python error unhandled exception in thread started by error in sys.excepthook
- How to Fix Exception in thread “main“ com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications
- Cause check of unreachable statement exception in Java
- Exception record. When eclipse starts, an error is reported when workspace is opened
- Solution to the exception of PEM file logging in EC2
- The solution to “polling news feeds” appeared in Eclipse in Java
- Solved: elasticsearch error: exception [type = search]_ phase_ execution_ exception, reason=all shards failed]
- Eclipse port occupied( java.net.BindException : address already in use: bind) solution