简体   繁体   English

JDK 7u3编译的“ Hello World!”程序是否可以与较旧的JRE(例如JRE 6)一起运行?

[英]Does “Hello World!” program compiled by JDK 7u3 runs with an older JREs (eg. JRE 6)?

Does Hello World! Hello World! program compiled by JDK 7u3 runs with an older JREs (eg. JRE 6)? JDK 7u3编译的程序是否与较旧的JRE(例如JRE 6)一起运行?

If the answer is YES , When a java program doesn't run with an older JRE? 如果答案是YESYES ,则Java程序不能与较早的JRE一起运行吗?

By default the class files produced by javac will have a version number appropriate for the JDK they were produced on. 默认情况下,由javac生成的类文件将具有与其所基于的JDK相适应的版本号。 To produce class files for earlier versions you will need to specify -target and to do that you will also need -source . 要为早期版本生成类文件,您需要指定-target并且还需要-source -source 1.6 -target 1.6 say. -source 1.6 -target 1.6说。

However, you will still be picking up the current Java library, which contain classes, methods (possibly overloads), etc., that were not in the previous version. 但是,您仍将选择当前的Java库,其中包含类,方法(可能是重载)等,而不是先前版本中的类。 To sort that out, use -bootclasspath to point to the rt.jar of the target JRE. 要解决此问题,请使用-bootclasspath指向目标JRE的rt.jar

Nope. 不。 You will get classloader exception complaining about non supported class version. 您将得到classloader异常,抱怨不支持的类版本。 Unless of course you specifically target lower version when compiling 除非您当然在编译时特别针对较低版本

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Eclipse如何区分“已安装的JRE”的JDK和JRE? - How does Eclipse differentiate JDK and JRE for the “Installed JREs”? 使用JDK 7u7构建的Applet在安装的JRE 7u72上运行 - 存在安全问题的风险吗? - Applet built using JDK 7u7, runs on JRE 7u72 installed - at risk for security issues in between? 在 Eclipse 中使用 JRE 与 JDK(已安装的 JRE?!),哪个更好? - Using JRE vs JDK (installed JREs?!) in Eclipse, what´s better? 使用较旧的JDK编译的Java代码无法与较新的JRE / JVM一起正常工作 - Java code compiled using an older JDK will not work properly with a newer JRE/JVM 较新的JRE版本可以运行用较旧的JDK版本编译的Java程序吗? - Can newer JRE versions run Java programs compiled with older JDK versions? 为什么最新的 jre 不能运行用旧版本的 jdk 编译的 jar? - Why latest jre won't run jar compiled with older version of jdk? 为什么每个JDK都带有3个JRE? - Why does each JDK come with 3 JREs? 安装JDK 7u3后找不到tools.jar - Can't find tools.jar after installing JDK 7u3 如何为使用 JDK 11 编译的 java 程序将 JRE 与 Launch4j 捆绑在一起? - How to bundle a JRE with Launch4j for my java program compiled with JDK 11? ConcurrentHashMap崩溃使用JDK 8编译但是以JRE 7为目标的应用程序 - ConcurrentHashMap crashing application compiled with JDK 8 but targeting JRE 7
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM