Super User is a question and answer site for computer enthusiasts and power users. 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 have downloaded the java jdk in the terminal window of Ubunutu. I am trying to trace the number of system calls a No-op java program runs for my computer science class. the program looks like so:

/* Java No-op program */

public class Noop {
  public static void main(String args[]) {
    System.exit(0);
  }
}

very simple.

It compiles using javac Noop.java and then in my directory, I get a Noop.class file. But when I try java Noop to run the program I get this error

Exception in thread "main" java.lang.UnsupportedClassVersionError: Noop : Unsopported 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.ClassLoader.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: Noop. Program will exit.

I have tried running other java programs that I know work, and same result.

Please Help.

share|improve this question
    
Is your JRE(Java Runtime Environment) up to date? – Fabián H. jr. Feb 5 '12 at 5:25

Sounds like your java doesn't match your javac. What output do you get from running java -version and javac -version?

share|improve this answer
    
Yeah when I did that it said my java compiler is 1.0.7_147 but my java is just 1.6.0_23. How do I fix this/update my java? – andrewpw Feb 5 '12 at 8:22
    
That's a really strange version of javac. What do you get from running type java and type javac? Although to make a long story short, if it's practical, I think the most expedient solution (and simplest to explain) is just to download the JDK straight from Sun/Oracle‌​. – jjlin Feb 5 '12 at 8:54

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .