Home > Software design >  java: cannot access org.springframework.boot.SpringApplication bad class file
java: cannot access org.springframework.boot.SpringApplication bad class file

Time:09-12

java: cannot access org.springframework.boot.SpringApplication
  bad class file: /C:/Users/xyz/.m2/repository/org/springframework/boot/spring-boot/3.0.0-SNAPSHOT/spring-boot-3.0.0-20220910.145857-773.jar!/org/springframework/boot/SpringApplication.class
    class file has wrong version 61.0, should be 52.0
    Please remove or make sure it appears in the correct subdirectory of the classpath.

CodePudding user response:

If you have java 8 installed on your machine and if you go to the spring initializer website and create an application by selecting Spring boot 3.0.0 (SNAPSHOT) and packaging as Jar and version as 8, then generated zip file will have version as 11 on pom even though you selected version as 8. which means, your local machine is having java version 8, and the generated zip file is having version 11 on the pom.

enter image description here

CodePudding user response:

class file has wrong version 61.0, should be 52.0

Referring to List of Java class file format major version numbers?. and similar question Class file has wrong version 52.0, should be 50.0 It indicates that you are using java 8 but the class file is compiled for java 17.
The reason is Spring Boot 3 requires java 17, as stated in Preparing for Spring Boot 3.0.

  • Related