Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I get following error when I try to run a Java program

Exception in thread "main" java.lang.UnsupportedClassVersionError: Abc : Unsupported major.minor version 51.0
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(
    at Method)
    at java.lang.ClassLoader.loadClass(
    at sun.misc.Launcher$AppClassLoader.loadClass(
    at java.lang.ClassLoader.loadClass(
Could not find the main class: Abc. Program will exit.
share|improve this question

However, the error appears to be due to trying to run something compiled with Java 7 (class file version 51) with an earlier version of the Java interpreter.

Ubuntu 12.04 comes by default with OpenJDK 6, but version 7 is available in the repositories.

In a terminal

sudo apt-get install openjdk-7-jre

(or search for it in the software centre)

If you want to do any java development rather than just run a program you'll need also openjdk-7-jdk

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.