Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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(ClassLoader.java:634)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:277)
    at java.net.URLClassLoader.access$000(URLClassLoader.java:73)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:212)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
Could not find the main class: Abc. Program will exit.
share|improve this question
add comment

1 Answer 1

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
add comment

Your Answer

 
discard

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.