较新的JRE版本可以运行使用旧版JDK编译的Java程序吗? [英] Can newer JRE versions run Java programs compiled with older JDK versions?

查看:236
本文介绍了较新的JRE版本可以运行使用旧版JDK编译的Java程序吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这可能是一个愚蠢的问题,但是我会遇到运行Java程序和使用Java版本1.6 1.7编译的相关库的任何问题(我正在使用1.7进行编译,而有些库是使用1.6编译的)并在1.7 JRE中运行整个程序?

This may be a stupid question, but would I encounter any problems running Java programs and associated libraries compiled in Java version 1.6 and 1.7 (I'm compiling using 1.7 whereas some libraries are compiled using 1.6) and running the entire program in a 1.7 JRE?

推荐答案

你不会遇到任何问题 - 这就是Java-it的神奇之处向后兼容。您可以在Java 8上运行几乎所有来自Java 1的代码。没有理由说Java 6代码不能在Java 8 Runtime上运行。

You would not encounter any problems - that's the magic of Java -it's backwards compatible.You can run almost all code from Java 1 on Java 8. There's no reason why Java 6 code won't run on a Java 8 Runtime.

什么是有趣的是,对于写入的应用程序,比如Java 1.4,在以后的运行时运行它们时甚至可以提高速度。这是因为Java不断发展,不仅仅是称为Java的语言,还有JVM(Java虚拟机)。我仍然有超过10年前的源代码仍然有效,正如在最新的JVM中所期望的那样。

What is interesting, is that for applications written in, let's say, Java 1.4, you even have speed increases when running them on later runtimes. This is because Java is constantly evolving, not just the language known as "Java", but also the JVM (Java virtual machine). I still have source code from more than 10 years ago that still work, as expected in the latest JVM.

如果你想要定位,比如说,Java 5 VM ,那么你可以使用Java 8 SDK工具做到这一点。您可以最终指定您希望支持的目标VM,只要您记住版本5 VM可能不支持版本8 VM的所有功能。

If you want to target, let's say, a Java 5 VM, then you can do that with the Java 8 SDK tools. You can ultimately specify which target VM you wish to support, as long as you bear in mind that a version 5 VM might not support all the features a version 8 VM will.

我刚刚测试了我在Java 5中编写的针对新Java 8运行时的代码,一切都按预期工作,因此,即使我们现在拥有更强大的语言和运行时,我们仍可以继续使用过去的投资。只是这一点使Java成为公司的一个伟大的发展选择。

I've just tested code I wrote in Java 5 against the new Java 8 runtime and everything works as expected, so, even though we have a more powerful language and runtime now, we can continue to use our investments of the past. Just that alone makes Java a great development choice for companies.

这篇关于较新的JRE版本可以运行使用旧版JDK编译的Java程序吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆