java javac:目标版本 7 与默认源版本 1.8 冲突
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/35710600/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
javac: target release 7 conflicts with default source release 1.8
提问by michealAtmi
I am playing with javac and I cant compile simple java class to 1.7 version.
我正在使用 javac,但无法将简单的 java 类编译为 1.7 版本。
C:\Tests>javac -target 7 GreetingsUniverse.java -nowarn
javac: target release 7 conflicts with default source release 1.8
C:\Tests>javac -version
javac 1.8.0_73
What could be the reason?
可能是什么原因?
回答by Bill K
add a -source that matches your -target, so 1.7 I believe. Should fix it.
添加一个与您的 -target 匹配的 -source,所以我相信 1.7。应该修复它。
Otherwise you are compiling all those cool 1.8 closures onto a 1.7 jar to run on a 1.7 jvm which is just not going to work.
否则,您将所有这些很酷的 1.8 闭包编译到 1.7 jar 上,以在 1.7 jvm 上运行,但这是行不通的。
回答by Kedar Mhaswade
This simply means that the javac
program from a JDK release with version 1.n
can be run on a java
program from release 1.n
or higher.
这只是意味着javac
来自具有版本的 JDK 发行版1.n
的java
程序可以在发行版1.n
或更高版本的程序上运行。
You are using javac
from the JDK release 1.8.0_73
which means the compiled bytecode can be executed only by a JRE release 1.8
or higher.
您使用javac
的是 JDK 版本1.8.0_73
,这意味着编译后的字节码只能由 JRE 版本1.8
或更高版本执行。