I have downloaded Spring Tool Suite4 IDE, Java17 Came Along with that IDE. But i want to work on Java8.
I installed only java8 in my system and started working on to print just "Hello Spring Boot".
When i run the sample project the code is being compiled with java17 and trying to run with java8(which i have given in execution environments and build path)
I got error like below.
Exception in thread "main" java.lang.UnsupportedClassVersionError: org/springframework/boot/SpringApplication has been compiled by a more recent version of the Java Runtime (class file version 61.0), this version of the Java Runtime only recognizes class file versions up to 52.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:756)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:473)
at java.net.URLClassLoader.access$100(URLClassLoader.java:74)
at java.net.URLClassLoader$1.run(URLClassLoader.java:369)
at java.net.URLClassLoader$1.run(URLClassLoader.java:363)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:362)
at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:355)
at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
at com.aditya.springboot.HelloSpringBootProjectApplication.main(HelloSpringBootProjectApplication.java:10)
I changed the compiler compliance from 17 to 1.8 in windows-\>preferences-\>Compiler-\>JDK Compliance..,
I pointed the Installed JREs to from jre 17(default) to jdk 1.8 and
I changed the compiler compliance from 17 to 1.8 in project-\>properties-\>java compiler also.
I tried uninstalling the STS4 and reinstalling it, but still i am getting same error.
As i am using maven project i tried changing \<java.version\> to 1.8 from 17 in pom.xml file too.
Can anyone help me from where STS is taking java17 inorder to compile my code, i haven't installed java17 in my system also. I have pointed JAVA_HOME in enviroment variables(user level variable but not system level varaiable) to java8 only.