java.lang.UnsupportedClassVersionError

If you like a tip written by other Samebug users, mark is as helpful! Marks help our algorithm provide you better solutions and also help other users.
tip

Update "latest" to Java 8 on DockerHub.

tip

This might be caused by and outdated version of Java, SonarQube now uses Java 8 as default. You might upgrade java or use an older version of SonarQube.

tip

You're using an older version of java with classes compiled for java7

tip

If you're using intellij plugin of sonarqube, you might have to set the JAVA_HOME ambient variable manually.

You have a different solution? A short tip here would help you and many other users who saw this issue last week.

  • UnsupportedClassVersionError when running build with jdk 1.5 To reproduce : Declare JDK 5 in jenkins configuration Create a job : freestyle project Configure job : with Ant/Ivy-Artifactory Integration Stacktrace : [latest] $ /usr/lib/ant/apache-ant-1.7.1/bin/ant -file build.xml livraison -v -lib /var/lib/jenkins/plugins/artifactory/WEB-INF/lib -listener org.jfrog.build.extractor.listener.ArtifactoryBuildListener Apache Ant version 1.7.1 compiled on June 27 2008 Buildfile: build.xml BUILD FAILED Class org.jfrog.build.extractor.listener.ArtifactoryBuildListener could not be loaded because of an invalid dependency. at org.apache.tools.ant.util.ClasspathUtils.newInstance(ClasspathUtils.java:296) at org.apache.tools.ant.Main.addBuildListeners(Main.java:799) at org.apache.tools.ant.Main.runBuild(Main.java:681) at org.apache.tools.ant.Main.startAnt(Main.java:217) at org.apache.tools.ant.launch.Launcher.run(Launcher.java:257) at org.apache.tools.ant.launch.Launcher.main(Launcher.java:104) Caused by: java.lang.UnsupportedClassVersionError: Bad version number in .class file at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:621) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124) at java.net.URLClassLoader.defineClass(URLClassLoader.java:260) at java.net.URLClassLoader.access$100(URLClassLoader.java:56) at java.net.URLClassLoader$1.run(URLClassLoader.java:195) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:188) at java.lang.ClassLoader.loadClass(ClassLoader.java:307) at java.lang.ClassLoader.loadClass(ClassLoader.java:252) at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:242) at org.apache.tools.ant.util.ClasspathUtils.newInstance(ClasspathUtils.java:266) ... 5 more --- Nested Exception --- java.lang.UnsupportedClassVersionError: Bad version number in .class file at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:621) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124) at java.net.URLClassLoader.defineClass(URLClassLoader.java:260) at java.net.URLClassLoader.access$100(URLClassLoader.java:56) at java.net.URLClassLoader$1.run(URLClassLoader.java:195) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:188) at java.lang.ClassLoader.loadClass(ClassLoader.java:307) at java.lang.ClassLoader.loadClass(ClassLoader.java:252) at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:242) at org.apache.tools.ant.util.ClasspathUtils.newInstance(ClasspathUtils.java:266) at org.apache.tools.ant.Main.addBuildListeners(Main.java:799) at org.apache.tools.ant.Main.runBuild(Main.java:681) at org.apache.tools.ant.Main.startAnt(Main.java:217) at org.apache.tools.ant.launch.Launcher.run(Launcher.java:257) at org.apache.tools.ant.launch.Launcher.main(Launcher.java:104) Note : build-info-api-2.0.7.jar build-info-client-2.0.7.jar build-info-extractor-2.0.7.jar build-info-vcs-2.0.7.jar => seems to be compile with jdk 1.6
    via by Sébastien Heurtematte,
  • UnsupportedClassVersionError when running build with jdk 1.5 To reproduce : Declare JDK 5 in jenkins configuration Create a job : freestyle project Configure job : with Ant/Ivy-Artifactory Integration Stacktrace : [latest] $ /usr/lib/ant/apache-ant-1.7.1/bin/ant -file build.xml livraison -v -lib /var/lib/jenkins/plugins/artifactory/WEB-INF/lib -listener org.jfrog.build.extractor.listener.ArtifactoryBuildListener Apache Ant version 1.7.1 compiled on June 27 2008 Buildfile: build.xml BUILD FAILED Class org.jfrog.build.extractor.listener.ArtifactoryBuildListener could not be loaded because of an invalid dependency. at org.apache.tools.ant.util.ClasspathUtils.newInstance(ClasspathUtils.java:296) at org.apache.tools.ant.Main.addBuildListeners(Main.java:799) at org.apache.tools.ant.Main.runBuild(Main.java:681) at org.apache.tools.ant.Main.startAnt(Main.java:217) at org.apache.tools.ant.launch.Launcher.run(Launcher.java:257) at org.apache.tools.ant.launch.Launcher.main(Launcher.java:104) Caused by: java.lang.UnsupportedClassVersionError: Bad version number in .class file at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:621) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124) at java.net.URLClassLoader.defineClass(URLClassLoader.java:260) at java.net.URLClassLoader.access$100(URLClassLoader.java:56) at java.net.URLClassLoader$1.run(URLClassLoader.java:195) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:188) at java.lang.ClassLoader.loadClass(ClassLoader.java:307) at java.lang.ClassLoader.loadClass(ClassLoader.java:252) at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:242) at org.apache.tools.ant.util.ClasspathUtils.newInstance(ClasspathUtils.java:266) ... 5 more --- Nested Exception --- java.lang.UnsupportedClassVersionError: Bad version number in .class file at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:621) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124) at java.net.URLClassLoader.defineClass(URLClassLoader.java:260) at java.net.URLClassLoader.access$100(URLClassLoader.java:56) at java.net.URLClassLoader$1.run(URLClassLoader.java:195) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:188) at java.lang.ClassLoader.loadClass(ClassLoader.java:307) at java.lang.ClassLoader.loadClass(ClassLoader.java:252) at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:242) at org.apache.tools.ant.util.ClasspathUtils.newInstance(ClasspathUtils.java:266) at org.apache.tools.ant.Main.addBuildListeners(Main.java:799) at org.apache.tools.ant.Main.runBuild(Main.java:681) at org.apache.tools.ant.Main.startAnt(Main.java:217) at org.apache.tools.ant.launch.Launcher.run(Launcher.java:257) at org.apache.tools.ant.launch.Launcher.main(Launcher.java:104) Note : build-info-api-2.0.7.jar build-info-client-2.0.7.jar build-info-extractor-2.0.7.jar build-info-vcs-2.0.7.jar => seems to be compile with jdk 1.6
    via by Sébastien Heurtematte,
  • Java .jar not running in unix
    via Stack Overflow by TyC
    ,
  • Java
    via by Unknown author,
  • Java?
    via by Unknown author,
    • java.lang.UnsupportedClassVersionError: Bad version number in .class file at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:621) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124) at java.net.URLClassLoader.defineClass(URLClassLoader.java:260) at java.net.URLClassLoader.access$100(URLClassLoader.java:56) at java.net.URLClassLoader$1.run(URLClassLoader.java:195) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:188) at java.lang.ClassLoader.loadClass(ClassLoader.java:307) at java.lang.ClassLoader.loadClass(ClassLoader.java:252) at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:242) at org.apache.tools.ant.util.ClasspathUtils.newInstance(ClasspathUtils.java:266) at org.apache.tools.ant.Main.addBuildListeners(Main.java:799) at org.apache.tools.ant.Main.runBuild(Main.java:681) at org.apache.tools.ant.Main.startAnt(Main.java:217) at org.apache.tools.ant.launch.Launcher.run(Launcher.java:257) at org.apache.tools.ant.launch.Launcher.main(Launcher.java:104)

    Users with the same issue

    harshg
    2 times, last one,
    Unknown visitor2 times, last one,
    Unknown visitor1 times, last one,
    Unknown visitor1 times, last one,
    Unknown visitor1 times, last one,
    195 more bugmates