Wednesday 21 December 2016

java - Eclipse Luna IDE projects won't run




Today I upgraded to Eclipse Luna, on my Linux machine. Everything seemed to work until I ran a "Hello World" program.
It gave me this error:




Exception in thread "main" java.lang.UnsupportedClassVersionError: test/test : Unsupported major.minor version 52.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:643)
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:323)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
at java.lang.ClassLoader.loadClass(ClassLoader.java:268)


Could not find the main class: test.test. Program will exit.



Obviously, I have the main method and everything correct, but it's not working.
Also for some reason I am using JRE System Library [jkd-6-openjdk-amd64], when I believe I need to be using JRE System Library [1.8], but I couldn't find it installed.




Checking java -version in the terminal confirms that 1.8 is installed.
Any help fixing this?



Thanks.


Answer



Major Minor version 52.0 which means you have JDK and JRE version mismatch.
Suppose that you are using jre8 for your environment settings, then you have to define JDK8 path for Eclipse as well.
You can do it as following:



-vm 

..\path-to-jre\bin\javaw.exe

No comments:

Post a Comment

c++ - Does curly brackets matter for empty constructor?

Those brackets declare an empty, inline constructor. In that case, with them, the constructor does exist, it merely does nothing more than t...