Nothingbutageek
Nothingbutageek

Reputation: 417

can't run java programs in eclipse on mac

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)

Upvotes: 1

Views: 2222

Answers (1)

Robin Green
Robin Green

Reputation: 33033

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.

Upvotes: 2

Related Questions