0

running fedora 20 and using gedit as my editor. when i compile my program and then try to run it using terminal, this happens:

Unsupported major.minor version 52.0 at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:800) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) at java.net.URLClassLoader.defineClass(URLClassLoader.java:449) at java.net.URLClassLoader.access$100(URLClassLoader.java:71) at java.net.URLClassLoader$1.run(URLClassLoader.java:361) at java.net.URLClassLoader$1.run(URLClassLoader.java:355) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:354) at java.lang.ClassLoader.loadClass(ClassLoader.java:425) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308) at java.lang.ClassLoader.loadClass(ClassLoader.java:358) at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:482) ABRT problem creation: 'success' i have tried the simple google search but all i can find out is that the program is being compiled using a later version of java and being run with another. however, all the solutions i came across are based on eclipse and i am not using this.

please help!

  • When you run `java -version` and `javac -version` what version numbers does it return for java and javac? – Bohuslav Burghardt Oct 26 '14 at 19:26
  • for java -version it says "1.7.0_71" and for javac version "1.8.0_20" which is exactly what i thought the problem is right? –  Oct 26 '14 at 19:32
  • 1
    Yes that is the problem. You are probably using JRE 1.7 alongsinde JDK 1.8. Have you tried uninstalling the JRE 1.7 if you don't need it for anything? Then java command from JDK 1.8 would be used. Or you can run `sudo update-alternatives --config java` to set your preferred java version. – Bohuslav Burghardt Oct 26 '14 at 19:41
  • i have not tried uninstalling JRE 1.7 forgive me i am new to all of this, im not sure whether i need it or not. when i run 'sudo update-alternatives --config java' it says There is 1 program that provides 'java'. Selection Command ----------------------------------------------- *+ 1 /usr/lib/jvm/java-1.7.0-openjdk-1.7.0.71-2.5.3.0.fc20.x86_64/jre/bin/java Enter to keep the current selection[+], or type selection number –  Oct 26 '14 at 19:46
  • And do you know where is your JDK 1.8 located? Is it Oracle JDK or OpenJDK? Have you installed it manually by extracting the downloaded archive somewhere or from repository? If you know where the JDK is located (running `which javac` should give you the answer) you can specify that location to update-alternatives command if it does not find the JDK installation itself as in your case (`sudo update-alternatives --install "/usr/bin/java" "java" "" 1`). – Bohuslav Burghardt Oct 26 '14 at 19:51
  • it is OpenJDK i found out using the java -version command you told me. I cant remember how i installed it. when i run "which javac" i get: /usr/bin/java sorry but i dont undersand what you mean by "path to java command in your JDK install" i appreciate your help –  Oct 26 '14 at 19:59
  • OK maybe the easiest solution will be uninstalling JRE 7 in your case. Please try running `sudo yum remove java-1.7.0-openjdk`. – Bohuslav Burghardt Oct 26 '14 at 20:13
  • ok i removed java-1.7.0-openjdk now how do i install the new version? –  Oct 26 '14 at 20:20
  • You should be able to use java from your JDK 1.8 by now. Have you tried compiling and running your program now? If it does not work then probably PATH or symlinks to java are not correctly set up. In that case try (re)installing your Java 8 installation using `sudo yum install java-1.8.0-openjdk` to see if that helps. – Bohuslav Burghardt Oct 26 '14 at 20:29
  • yes it is not working and i think you might be right in suggesting the PATH. I have installed java-1.8.0-openjdk and it is still not working.. –  Oct 26 '14 at 20:41
  • Try to re-run `sudo update-alternatives --config java`. Now that you've installed java-1.8.0-jdk it should work (at least it did for me when I've tried to do it on a clean Fedora install). – Bohuslav Burghardt Oct 27 '14 at 15:55
  • it worked now that i ran that again. thank you so much for your help, highly appreciate it! –  Oct 27 '14 at 18:35

2 Answers2

1

The error that you are getting because you are using different version of Java. Try down grading to Java 1.7 or Java 1.6 if you are using Java 1.8.

Hope this helps.

  • 2
    Could you provide a bit more information about why that would help, and how to tell which version would work? – SamB Dec 26 '14 at 06:04
0

It will help you. Its because, your compiler and JVM versions mismatch. Your IDE tools might have options to change Compiler version.

Unsupported major.minor version 52.0

How to fix java.lang.UnsupportedClassVersionError: Unsupported major.minor version

Community
  • 1
  • 1
Chowdappa
  • 1,580
  • 1
  • 15
  • 31