1

i bought macbook pro just today and i'm trying to get my programs, projects which was on normal windows. I downloaded eclipse for Java developers for MAC OS. But after getting eclipse working i realised that my programs which was written before was not able to compile and so. Even in simple hello world program, i have downloaded JDK 7 for mac and place it as same file as eclipse but it doesn't work what should i do ? The errors I'm getting from eclipse when i try to run my program is:

Exception in thread "main" java.lang.UnsupportedClassVersionError: HelloWorld : Unsupported major.minor version 51.0
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClassCond(ClassLoader.java:637)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:621)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
    at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
Nothingbutageek
  • 357
  • 1
  • 11
  • Take a look at : http://stackoverflow.com/questions/2466828/java-lang-unsupportedclassversionerror-bad-version-number-in-class-file – NickJ Nov 20 '13 at 22:10

1 Answers1

2

The problem is that JDK 7 is not being used to run your program.

You cannot simply place JDK 7 in your Eclipse directory and expect it to be used. It's not that easy.

You need to configure Eclipse to use the JDK 7 that you have installed as your Runtime Environment. This can either be done on a per-project basis or workspace-wide.

Robin Green
  • 32,079
  • 16
  • 104
  • 187
  • in windows, we had something like path to make our workspace use jdk but in mac? how can we do it then? did i understand the problem that you mention? – Nothingbutageek Nov 20 '13 at 22:09
  • Eclipse can use different JDKs for different purposes. E.g. one JDK to run itself, another JDK (to be precise, Java version) to compile for, and another to run your programs. You might need to configure the correct one - see the *answers* to this question (please ignore the question itself, it is rather confusing): http://stackoverflow.com/questions/17928644/using-both-jdk-1-6-and-jdk-1-7-for-different-projects-in-eclipse – Robin Green Nov 20 '13 at 22:34
  • first answer in the topic you have given was very useful and made me solve the problem. Thanks – Nothingbutageek Nov 21 '13 at 15:57