JRE 1.7 and Spark version 2.6.0. having exception java.lang.UnsupportedClassVersionError: spark/Route : Unsupported major.minor version 52.0 [duplicate]

Home / Uncategorized / JRE 1.7 and Spark version 2.6.0. having exception java.lang.UnsupportedClassVersionError: spark/Route : Unsupported major.minor version 52.0 [duplicate]

Question:
This question already has an answer here:How to fix java.lang.UnsupportedClassVersionError: Unsupported major.minor version 41 answers

I am using JRE 1.7 with spark version 2.6.0 and IDE as InteliJ idea. Source of my class is as below:package com.tengen;

import spark.Request;
import spark.Response;
import spark.Route;
import spark.Spark;

public class HelloWorldSparkStyle {
public static void main(String[] args) {
Spark.get("/",new Route() {
@Override
public Object handle(final Request request, final Response response) throws Exception {
return "Hello World from Spark";
}
});
}
}

I get this exception when I try to run this class:"C:Program FilesJavajdk1.7.0_80binjava" "-javaagent:C:Program FilesJetBrainsIntelliJ IDEA Community Edition 2017.2.1libidea_rt.jar=4388:C:Program FilesJetBrainsIntelliJ IDEA Community Edition 2017.2.1bin" -Dfile.encoding=UTF-8 -classpath "C:Program FilesJavajdk1.7.0_80jrelibcharsets.jar;C:Program FilesJavajdk1.7.0_80jrelibdeploy.jar;C:Program FilesJavajdk1.7.0_80jrelibextaccess-bridge-64.jar;C:Program FilesJavajdk1.7.0_80jrelibextdnsns.jar;C:Program FilesJavajdk1.7.0_80jrelibextjaccess.jar;C:Program FilesJavajdk1.7.0_80jrelibextlocaledata.jar;C:Program FilesJavajdk1.7.0_80jrelibextsunec.jar;C:Program FilesJavajdk1.7.0_80jrelibextsunjce_provider.jar;C:Program FilesJavajdk1.7.0_80jrelibextsunmscapi.jar;C:Program FilesJavajdk1.7.0_80jrelibextzipfs.jar;C:Program FilesJavajdk1.7.0_80jrelibjavaws.jar;C:Program FilesJavajdk1.7.0_80jrelibjce.jar;C:Program FilesJavajdk1.7.0_80jrelibjfr.jar;C:Program FilesJavajdk1.7.0_80jrelibjfxrt.jar;C:Program FilesJavajdk1.7.0_80jrelibjsse.jar;C:Program FilesJavajdk1.7.0_80jrelibmanagement-agent.jar;C:Program FilesJavajdk1.7.0_80jrelibplugin.jar;C:Program FilesJavajdk1.7.0_80jrelibresources.jar;C:Program FilesJavajdk1.7.0_80jrelibrt.jar;C:UsersnaeemjM101JtargetM101J-1.0-SNAPSHOTWEB-INFclasses;C:Usersnaeemj.m2repositoryorgspringframeworkbootspring-boot-starter-web1.2.5.RELEASEspring-boot-starter-web-1.2.5.RELEASE.jar;C:Usersnaeemj.m2repositoryorgspringframeworkbootspring-boot-starter1.2.5.RELEASEspring-boot-starter-1.2.5.RELEASE.jar;C:Usersnaeemj.m2repositoryorgspringframeworkbootspring-boot1.2.5.RELEASEspring-boot-1.2.5.RELEASE.jar;C:Usersnaeemj.m2repositoryorgspringframeworkbootspring-boot-autoconfigure1.2.5.RELEASEspring-boot-autoconfigure-1.2.5.RELEASE.jar;C:Usersnaeemj.m2repositoryorgspringframeworkbootspring-boot-starter-logging1.2.5.RELEASEspring-boot-starter-logging-1.2.5.RELEASE.jar;C:Usersnaeemj.m2repositoryorgslf4jjcl-over-slf4j1.7.12jcl-over-slf4j-1.7.12.jar;C:Usersnaeemj.m2repositoryorgslf4jjul-to-slf4j1.7.12jul-to-slf4j-1.7.12.jar;C:Usersnaeemj.m2repositoryorgslf4jlog4j-over-slf4j1.7.12log4j-over-slf4j-1.7.12.jar;C:Usersnaeemj.m2repositorychqoslogbacklogback-classic1.1.3logback-classic-1.1.3.jar;C:Usersnaeemj.m2repositorychqoslogbacklogback-core1.1.3logback-core-1.1.3.jar;C:Usersnaeemj.m2repositoryorgyamlsnakeyaml1.14snakeyaml-1.14.jar;C:Usersnaeemj.m2repositorycomfasterxmljacksoncorejackson-databind2.4.6jackson-databind-2.4.6.jar;C:Usersnaeemj.m2repositorycomfasterxmljacksoncorejackson-annotations2.4.6jackson-annotations-2.4.6.jar;C:Usersnaeemj.m2repositorycomfasterxmljacksoncorejackson-core2.4.6jackson-core-2.4.6.jar;C:Usersnaeemj.m2repositoryorghibernatehibernate-validator4.3.2.Finalhibernate-validator-4.3.2.Final.jar;C:Usersnaeemj.m2repositoryjavaxvalidationvalidation-api1.0.0.GAvalidation-api-1.0.0.GA.jar;C:Usersnaeemj.m2repositoryorgjbossloggingjboss-logging3.1.0.CR2jboss-logging-3.1.0.CR2.jar;C:Usersnaeemj.m2repositoryorgspringframeworkspring-core4.1.7.RELEASEspring-core-4.1.7.RELEASE.jar;C:Usersnaeemj.m2repositoryorgspringframeworkspring-web4.1.7.RELEASEspring-web-4.1.7.RELEASE.jar;C:Usersnaeemj.m2repositoryorgspringframeworkspring-aop4.1.7.RELEASEspring-aop-4.1.7.RELEASE.jar;C:Usersnaeemj.m2repositoryaopallianceaopalliance1.0aopalliance-1.0.jar;C:Usersnaeemj.m2repositoryorgspringframeworkspring-beans4.1.7.RELEASEspring-beans-4.1.7.RELEASE.jar;C:Usersnaeemj.m2repositoryorgspringframeworkspring-context4.1.7.RELEASEspring-context-4.1.7.RELEASE.jar;C:Usersnaeemj.m2repositoryorgspringframeworkspring-webmvc4.1.7.RELEASEspring-webmvc-4.1.7.RELEASE.jar;C:Usersnaeemj.m2repositoryorgspringframeworkspring-expression4.1.7.RELEASEspring-expression-4.1.7.RELEASE.jar;C:Usersnaeemj.m2repositoryorgspringframeworkbootspring-boot-starter-thymeleaf1.2.5.RELEASEspring-boot-starter-thymeleaf-1.2.5.RELEASE.jar;C:Usersnaeemj.m2repositoryorgthymeleafthymeleaf-spring42.1.4.RELEASEthymeleaf-spring4-2.1.4.RELEASE.jar;C:Usersnaeemj.m2repositoryorgthymeleafthymeleaf2.1.4.RELEASEthymeleaf-2.1.4.RELEASE.jar;C:Usersnaeemj.m2repositoryognlognl3.0.8ognl-3.0.8.jar;C:Usersnaeemj.m2repositoryorgjavassistjavassist3.18.1-GAjavassist-3.18.1-GA.jar;C:Usersnaeemj.m2repositoryorgunbescapeunbescape1.1.0.RELEASEunbescape-1.1.0.RELEASE.jar;C:Usersnaeemj.m2repositorynznetultraqthymeleafthymeleaf-layout-dialect1.2.9thymeleaf-layout-dialect-1.2.9.jar;C:Usersnaeemj.m2repositoryorgspringframeworkbootspring-boot-starter-actuator1.2.5.RELEASEspring-boot-starter-actuator-1.2.5.RELEASE.jar;C:Usersnaeemj.m2repositoryorgspringframeworkbootspring-boot-actuator1.2.5.RELEASEspring-boot-actuator-1.2.5.RELEASE.jar;C:Usersnaeemj.m2repositoryorgspringframeworkbootspring-boot-legacy1.0.1.RELEASEspring-boot-legacy-1.0.1.RELEASE.jar;C:Usersnaeemj.m2repositorycomgoogleappengineappengine-api-1.0-sdk1.9.17appengine-api-1.0-sdk-1.9.17.jar;C:Usersnaeemj.m2repositorycomgithubkernel164gmultipart.4gmultipart-0.4.jar;C:Usersnaeemj.m2repositorycommons-fileuploadcommons-fileupload1.2.2commons-fileupload-1.2.2.jar;C:Usersnaeemj.m2repositorycommons-iocommons-io2.0.1commons-io-2.0.1.jar;C:Usersnaeemj.m2repositorycomsparkjavaspark-core2.6.0spark-core-2.6.0.jar;C:Usersnaeemj.m2repositoryorgslf4jslf4j-api1.7.12slf4j-api-1.7.12.jar;C:Usersnaeemj.m2repositoryorgeclipsejettyjetty-server9.2.11.v20150529jetty-server-9.2.11.v20150529.jar;C:Usersnaeemj.m2repositoryjavaxservletjavax.servlet-api3.1.0javax.servlet-api-3.1.0.jar;C:Usersnaeemj.m2repositoryorgeclipsejettyjetty-http9.2.11.v20150529jetty-http-9.2.11.v20150529.jar;C:Usersnaeemj.m2repositoryorgeclipsejettyjetty-util9.2.11.v20150529jetty-util-9.2.11.v20150529.jar;C:Usersnaeemj.m2repositoryorgeclipsejettyjetty-io9.2.11.v20150529jetty-io-9.2.11.v20150529.jar;C:Usersnaeemj.m2repositoryorgeclipsejettyjetty-webapp9.2.11.v20150529jetty-webapp-9.2.11.v20150529.jar;C:Usersnaeemj.m2repositoryorgeclipsejettyjetty-xml9.2.11.v20150529jetty-xml-9.2.11.v20150529.jar;C:Usersnaeemj.m2repositoryorgeclipsejettyjetty-servlet9.2.11.v20150529jetty-servlet-9.2.11.v20150529.jar;C:Usersnaeemj.m2repositoryorgeclipsejettyjetty-security9.2.11.v20150529jetty-security-9.2.11.v20150529.jar;C:Usersnaeemj.m2repositoryorgeclipsejettywebsocketwebsocket-server9.2.11.v20150529websocket-server-9.2.11.v20150529.jar;C:Usersnaeemj.m2repositoryorgeclipsejettywebsocketwebsocket-common9.2.11.v20150529websocket-common-9.2.11.v20150529.jar;C:Usersnaeemj.m2repositoryorgeclipsejettywebsocketwebsocket-client9.2.11.v20150529websocket-client-9.2.11.v20150529.jar;C:Usersnaeemj.m2repositoryorgeclipsejettywebsocketwebsocket-servlet9.4.4.v20170414websocket-servlet-9.4.4.v20170414.jar;C:Usersnaeemj.m2repositoryorgeclipsejettywebsocketwebsocket-api9.4.4.v20170414websocket-api-9.4.4.v20170414.jar;C:Usersnaeemj.m2repositoryorgfreemarkerfreemarker2.3.26-incubatingfreemarker-2.3.26-incubating.jar" com.tengen.HelloWorldSparkStyle
java.lang.UnsupportedClassVersionError: spark/Route : 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 java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2625)
at java.lang.Class.getMethod0(Class.java:2866)
at java.lang.Class.getMethod(Class.java:1676)
at sun.launcher.LauncherHelper.getMainMethod(LauncherHelper.java:494)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:486)
Exception in thread "main"
Process finished with exit code 1


Answer:
you are using JRE 1.7 with spark version 2.6.0, you need to use Java 8 you can find below the version of the JRE the class file is compatible with this:Java SE 9 = 53,
Java SE 8 = 52,
Java SE 7 = 51,
Java SE 6.0 = 50,
Java SE 5.0 = 49,

for more you can refer below stackoverflow link Question By : ERJAN and Answer by : Many java Experts.

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

Leave a Reply

Your email address will not be published. Required fields are marked *