gpt4 book ai didi

operating-system - Java 可移植性不同 OS/JDK

转载 作者:行者123 更新时间:2023-12-01 15:38:13 28 4
gpt4 key购买 nike

我是“java 世界”的新手,所以我需要了解不同操作系统和 JDK 中可移植性的基础知识。我在互联网上看到的是,如果在 JDK 1.7 上编译一个程序,它将在任何 JDK 版本 >= 1.7 上运行,对吗?谢谢,我对我的英语表示歉意,这不是我的默认语言。

最佳答案

java中有一个选项-目标版本
它说...

Generate class files that target a specified version of the VM. Class files will run 
on the specified target and on later versions, but not on earlier versions of the VM.
Valid targets are 1.1, 1.2, 1.3,1.4, 1.5 (also 5), 1.6 (also 6), and 1.7 (also 7).

If -source is not specified, the value of -target is 1.7
If -source is 1.2, the value of -target is 1.4
If -source is 1.3, the value of -target is 1.4
If -source is 1.5, the value of -target is 1.7
If -source is 1.6, the value of -target is 1.7
For all other values of -source, the value of -target is the value of -source.

所以“如果在 JDK 1.7 上编译程序,它将在任何 JDK 版本 >= 1.7 上运行,这是正确的”

关于operating-system - Java 可移植性不同 OS/JDK,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8530034/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com