[英]Change java compiler version
I get this error when running my Java
application 运行
Java
应用程序时出现此错误
Global : Unsupported major.minor version 52.0
When I checked my Java
version, I found that it was different from the compiler version 当我检查我的
Java
版本时,我发现它与编译器版本不同
java -version
# java version "1.7.0_65"
# OpenJDK Runtime Environment (IcedTea 2.5.1) (7u65-2.5.1-4ubuntu1~0.12.04.2)
# OpenJDK Server VM (build 24.65-b04, mixed mode)
javac -version
# javac 1.8.0_20
How do I downgrade the Java compiler? 如何降级Java编译器?
Open a console. 打开一个控制台。 Type
类型
sudo update-alternatives --config javac
After entering your root password you can enter the number of a javac with "java-7" in its name. 输入root密码后,您可以在其名称中输入带有“java-7”的javac的编号。
Edit: You could also update-alternatives --config java
to choose a newer JVM that is compatible to Java 8 bytecode. 编辑:您还可以
update-alternatives --config java
以选择与Java 8字节码兼容的较新JVM。
You don't need to downgrade the compiler; 您不需要降级编译器; you just need to tell the compiler to produce classes that a Java 7 JVM will understand.
您只需告诉编译器生成Java 7 JVM将理解的类。 Use the options
-source 7 -target 7
when running javac
. 运行
javac
时使用选项-source 7 -target 7
。
I'm assuming you are using linux, 我假设你使用的是linux,
sudo update-alternatives --config javac
Then you can type your choice. 然后你可以输入你的选择。 If you get message like 'There is only one alternative...' then you should type to the terminal
如果您收到“只有一个替代方案......”的消息,那么您应该键入终端
sudo update-alternatives --install "/usr/bin/javac" "javac" "/(your java home)/bin/javac" 1
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.