When trying to run a class made in
This error is due to the fact that from the default Java Virtual Machine (Java Virtual Machine: Java Virtual Machine) of your computer, you try to execute a class that was compiled in a version of the JDK (Java Development Kit: Java Development Kit) higher than the JVM (for example, try to run a class compiled in JDK 1.6 with the JVM 1.4).
If you want to verify the version of the conflicting class, execute the command javap
which is the decompiler that is included in the JDK, executing it from %JAVA_HOME%\bin
(it is recommended to do it from the most recent version of the JDK).
For example, if you want to know in which version of Java the class MiClase.class
is compiled, execute the following commands:
javap -verbose MiClase.class | findstr "major"
which would return something like:
major version: 50
javap -verbose MiClase.class | findstr "minor"
which would return something like:
minor version: 0
Thus the equivalences between the versions of Java and their 'major version' are the following to the date:
Java 1.2 corresponds to major version 46
Java 1.3 corresponds to major version 47
Java 1.4 corresponds to major version 48
Java 5 corresponds to major version 49
Java 6 corresponds to major version 50
Java 7 corresponds to major version 51
Java 8 corresponds to major version 52
This is a simple way to do this check with the javap
command, although there are more. If you know them, you are welcome to make your contribution as a comment to this answer.
You are running your program with a lower version than the one with which it was compiled.
Example, compiled with 1.8 and try running in version 1.7