I remember getting this error while running some Java.
[crayon-5bf6893c77565835022143/] Because it is annoying, let’s take a look at this. What does this error mean?
It turns out to be an issue of version incompatibility. First of all, if you don’t know, here is some background on how Java is run.
1. The Java source code (the .java file) is compiled. This step generates a .class file with the same prefix as the .java. In other words, if your source code is Hello.java, your generated class file is Hello.class. This step is done by a Java compiler. If you run Java from command line, it is
2. Next, the .class file (called java bytecode) is run using a Java Virtual Machine (JVM). If you run in from command line, it is
Ok, back to error message. from Java class file, the number 51.0 is the version of the Java Class file (the ByteCode). 51 is Java 7, 50 is Java 6… The error message means that the Java Class file is compatible with Java 7 but the JVM is not. This happens when your source code was compiled by Java 7 and your run the bytecode with older JVM:
[crayon-5bf6893c7756f908171927/] How to fix it (for Linux Ubuntu)?
You can fix this by either compiling your source code with older Java compiler OR running your bytecode with newer Java virtual machine. I will show you the second way: Installing Oracle JDK 7, which includes the JVM into your machine.
1. Download JDK 7 from here. Choose JDK 7. Extract the compressed file.
2. Move the extracted folder into
3. Install the new Java into system:
[crayon-5bf6893c77574753608219/] The “jdk_verion” is the name of the Jdk folder that you download.
4. Update current version to Java 7:
[crayon-5bf6893c77578745964897/] Choose the new version that you just installed.
5. After installing, Run:
[crayon-5bf6893c7757b577644554/] to verify the change.
6. That’s basically it. If you run your Java inside Eclipse, you also need to update your Eclipse setting to make it work. In Eclipse Menu bar, open:
Windows/Preference/Java/Installed JREs. Click ‘Add’ and add the path to the JRE 7 in the
/usr/lib/jvm/jdk_version/jre. Apply, save and Eclipse should work fine.