Class file has wrong version 52.0, should be 50.0

前端 未结 6 2401
有刺的猬
有刺的猬 2020-11-29 10:21

I\'m trying to compile my project in IntelliJ idea. I\'m using a class in an external jar file and on compilation receiving the above error.

I understand that it\'s

相关标签:
6条回答
  • 2020-11-29 10:27

    i faced the same problem "Class file has wrong version 52.0, should be 50.0" when running java through ant... all i did was add fork="true" wherever i used the javac task and it worked...

    0 讨论(0)
  • 2020-11-29 10:29

    Select "File" -> "Project Structure".

    Under "Project Settings" select "Project"

    From there you can select the "Project SDK".

    0 讨论(0)
  • 2020-11-29 10:31

    In your IntelliJ idea find tools.jar replace it with tools.jar from yout JDK8

    0 讨论(0)
  • 2020-11-29 10:42

    It means your Java runtime version is 1.8, but your compiler version (javac) is 1.6. To simply solve it, just retreat the Java version from 1.8 to 1.6.

    But if you don't want to change the Java runtime version, then do the following steps:

    1. JAVA_HOME= "your jdk v1.8 folder path", to make sure jdk is also v1.8 and use java -version and javac -version again to ensure it
    2. Make sure IntelliJ 's compiler mode is set to compliant with v1.6 But i have tried that. it didn't solve my problem.
    0 讨论(0)
  • 2020-11-29 10:43

    If you are using javac to compile, and you get this error, then remove all the .class files

    rm *.class     # On Unix-based systems
    

    and recompile.

    javac fileName.java
    
    0 讨论(0)
  • 2020-11-29 10:45

    Have got the same error as in header because of failed attempt to compile my project with java 8 and then reattempting to compile with java 6. Some classes where compiled at the first attempt with 8 and did not recompile with 6. Mixed classes did not compile then. Cleaning project solved the problem. This answer is not strictly relevant to the question, but could be useful for someone.

    0 讨论(0)
提交回复
热议问题