执行./gradlew命令时报错unsupported major.minor version 52.0。
原因:
项目中使用的jdk是1.8,而使用的linux系统环境变量配置的java是1.7,这就导致了gradle脚本使用java1.8编译,而脚本执行时却用linux系统的java1.7,从而报错unsupported major.minor version 52.0(52.0就是java1.8的内部版本号)
解决: 将linux系统使用的java配置成jdk1.8即可,成功执行gradle脚本,好开心啊,困扰一天的问题解决了
参考:
Unsupported major.minor version 52.0 [duplicate]
up vote242down votefavorite 49 | This question already has an answer here: Pictures: Command Prompt showing versions Picture of error Hello.java Hello.html Error Does anyone know what the problem may be? java applet version unsupported-class-version
| ||||||||||||||||||||
marked as duplicate by ManoDestra, Ebbe M. Pedersen, Simon M�5�4Kenzie,ldg, George Garchagudashvili Jul 20 at 6:47This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question. | |||||||||||||||||||||
|
26 Answers
The issue is because of Java version mismatch. Referring to the Wikipedia Java Class Reference :
These are the reported major numbers. The error regarding the unsupportedmajor.minor version is because during compile time you are using a higher JDK and a lower JDK during runtime. Thus, the 'major.minor version 52.0' error is possibly because the jar is compiled in jdk 1.8, but you are trying to run it in jdk 1.7 environment. To solve this, it's always better to have the jdk and jre pointed to the same version. |