Home > database >  class file has wrong version 62.0, should be 57.0 - While building Jar
class file has wrong version 62.0, should be 57.0 - While building Jar

Time:02-02

I have downloaded Java code from GitHub and am trying to configure or build my changes into a Java package. But I'm getting the below error. I'm not sure what version of Java I need to use to build this project. Any pointers or suggestions would be really helpful.

error: cannot access Copier
import com.example.records.core.Copier;
                                    ^
  bad class file: /home/user957/.gradle/caches/modules-2/files-2.1/com.example.streaming/streaming-core/v1.36.1/758f1477d776e3273c5397d2d5d7e19b5fa46326/streaming-core-v1.36.1-sdk.jar(/com/example/records/core/Copier.class)
    class file has wrong version 62.0, should be 57.0
    Please remove or make sure it appears in the correct subdirectory of the classpath.

mySystem JDK version

java -version
openjdk version "18.0.2.1" 2022-08-18
OpenJDK Runtime Environment Temurin-18.0.2.1 1 (build 18.0.2.1 1)
OpenJDK 64-Bit Server VM Temurin-18.0.2.1 1 (build 18.0.2.1 1, mixed mode, sharing)

CodePudding user response:

Try JDK version 1.9 or higher. If class files has version 62.0,then least JDK 9 installed on system to be able to compile them

CodePudding user response:

I solved this problem, by just reinstalling my JDK. If you're using IntelliJ, just head to the project settings and click download in the JDK dropdown menu.

I also solved this problem on my Ubuntu 20.04 machine by running sudo apt install openjdk-13-jdk, which installs the jdk and sudo update-alternatives --config java, which updates the index of the newest jdk (i think).

If I understood you wrongly with the version needed, just adjust the number behind openjdk- to whatever version you need.

All versions to their corresponding class file versions

  • Related