Home > Software engineering >  Issue: java cannot access jakarta.persistence.Entity
Issue: java cannot access jakarta.persistence.Entity

Time:12-03

I am trying to build my (yet) simple Java Persistence Project with a MySql Database in the Background and try to access it via Rest over a Java Application. This all doesnt matter, because as soon as i try building my project I get an error by my Entity class that reads:

java: cannot access jakarta.persistence.Entity
  bad class file: /C:/Users/benja/.m2/repository/jakarta/persistence/jakarta.persistence-api/3.1.0/jakarta.persistence-api-3.1.0.jar!/jakarta/persistence/Entity.class
    class file has wrong version 55.0, should be 52.0
    Please remove or make sure it appears in the correct subdirectory of the classpath.

I checked the class path and everything seems alright, also i dont want to delete anything in there, because I managed to build a different project with a very similar structure already. Maybe its also an issue with the pom.xml, i basically copied it from another project because it worked there with the same JDK and MySQL version.

Im not very good with describing my problem, feel free to ask me further questions, thanks!

CodePudding user response:

according to this: List of Java class file format major version numbers?

55 - java 11 (so your jakarta lib is for java 11) 52 - the expected java which is 8

either move up you project java version to 11 (in your IDE and/or pom.xml) or use library for java 8.

  • Related