从Java 9到Java 8的兼容性和迁移 [英] Compatibility and migration from Java 9 to Java 8
问题描述
我正在阅读有关新Java 9模块的文档系统。
I'm reading the document about the new Java 9 module system.
段落 3兼容性&迁移解释了如何将代码
从Java 8迁移到Java 9,但没有说明如何迁移或运行用Java 9编写的应用程序
到Java 9之前的运行时。
The paragraph 3 Compatibility & migration explains how to migrate code from Java 8 to Java 9, but says nothing on how "migrate" or run an application written in Java 9 to pre Java 9 runtimes.
所以,如果我有,说一个用模块化方式编写的JAR应用程序(每个模块都有一个模块描述符)如果我将它部署在上面会发生什么? ,即JDK 8运行时?
So, if I have, say a JAR application written in a modularity way (every module has a module descriptor) what does happen if I deploy it on, i.e, a JDK 8 runtime?
推荐答案
您无法使用小于它的JRE启动Java应用程序用于。
You cannot start a Java application with a JRE which is less than the one it is built for.
如果您只使用 javac
而没有任何特殊选项,它将生成在JRE上运行的类或者大于使用过的JDK。
If you just use javac
without any special options it will produces classes which do run on JREs equal or bigger than the one of the used JDK.
然而,javac支持交叉编译。您可以使用JDK 8编译JDK 6兼容的类文件。在交叉编译选项 noreferrer> javac docs 。
However javac supports cross compilation. You can use JDK 8 to compile JDK 6 compatible class files. Search for Cross-Compilation Options in the javac docs.
这篇关于从Java 9到Java 8的兼容性和迁移的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!