-1

When i typed a small code in windows and compiled it a .class file produced,which should be processable i.e., it should show output after interpreting in every operating systems,and it was working well in terminal in Ubuntu(as i tried it in Ubuntu). But the same code when compiled in Ubuntu and a .class files was produced was not processable in cmd in windows i.e., cmd in windows doesnot shown an output rather shown this error

Exception in thread "main" java.lang.UnsupportedClassVersionError: UbuntuCode : Unsupported major.minor version 52.0
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:638)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:143)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:281)
    at java.net.URLClassLoader.access$000(URLClassLoader.java:74)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:216)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:209)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:324)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:269)
    at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:337)

where "UbuntuCode" is my file name. I already searched it on the internet but found only about installing jre,jvm,jdk or version mismatch and all. What is the reason behind this and how to resolve it. Thanks in advance. Help will be appreciated.

edit:- I had installed default jdk on Ubuntu and jdk1.7.0 on Windows

Weirdoooo
  • 243
  • 4
  • 10

2 Answers2

1

You don't have the correct jdk version to run your class. You need a JRE 8.

Pascal Heraud
  • 365
  • 2
  • 8
  • Which corresponds to that `52`. – Joop Eggen Dec 27 '16 at 17:28
  • I need JRE 8 at Windows or Ubuntu? And how to check which version of JRE i am using on Ubuntu because i installed default -jdk and i don't know which version Ubuntu automatically installed? – Weirdoooo Dec 27 '16 at 17:51
0

From the error, issue definitely seems to be related to Java version mismatch. Unsupported major.minor version 52.0 occurs when you are trying to run a class compiled using Java 1.8 compiler with lower JRE version. Can you check which version are you using on both windows and Ubuntu and post java -version output?

You can get more details at http://javarevisited.blogspot.com/2015/05/fixing-unsupported-majorminor-version.html#ixzz4AVD4Evgv

Nikhil Bhide
  • 728
  • 8
  • 23