用Java 8 JDK编译java 6安装
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了用Java 8 JDK编译java 6安装,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含2070字,纯文字阅读大概需要3分钟。
内容图文
![用Java 8 JDK编译java 6安装](/upload/InfoBanner/zyjiaocheng/805/593a548907264719b97c0cce02e24262.jpg)
我需要使用Java 6为大学编译我的源代码.我目前在我的PC(Linux)上安装了Java 8 JDK.如何在Java 6中编译?
附:我知道我不能使用任何Java 7或8功能.
p.p.s.我意识到Java 6源代码将使用Java 8 JDK编译得很好但是我发现在家里编译时我不小心在我的程序中使用了后Java 6功能.当我尝试在uni的实验室计算机上编译源代码时,我遇到了一堆错误.例如无法将对象强制转换为基元.
解决方法:
解决该问题的方法是使用更高版本的SDK进行编译,并在编译时使用cross compilation options.
Cross-Compilation Options
By default, classes are compiled against the bootstrap and extension classes of the platform that javac shipped with. But javac also supports cross-compiling, where classes are compiled against a bootstrap and extension classes of a different Java platform implementation. It is important to use the -bootclasspath and -extdirs options when cross-compiling.
-target version
Generates class files that target a specified release of the virtual machine. Class files will run on the specified target and on later releases, but not on earlier releases of the JVM. Valid targets are 1.1, 1.2, 1.3, 1.4, 1.5 (also 5), 1.6 (also 6), 1.7 (also 7), and 1.8 (also 8).
The default for the -target option depends on the value of the -source option:
- If the -source option is not specified, then the value of the -target option is 1.8
- If the -source option is 1.2, then the value of the -target option is 1.4
- If the -source option is 1.3, then the value of the -target option is 1.4
- If the -source option is 1.5, then the value of the -target option is 1.8
- If the -source option is 1.6, then the value of the -target is option 1.8
- If the -source option is 1.7, then the value of the -target is option 1.8
- For all other values of the -source option, the value of the -target option is the value of the -source option.
-bootclasspath bootclasspath
Cross-compiles against the specified set of boot classes. As with the user class path, boot class path entries are separated by colons (:) and can be directories, JAR archives, or ZIP archives.
要完全正确地使用这些选项(即也使用-bootclasspath选项),需要目标版本的JRE(而不是JDK)的rt.jar.
内容总结
以上是互联网集市为您收集整理的用Java 8 JDK编译java 6安装全部内容,希望文章能够帮你解决用Java 8 JDK编译java 6安装所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。