简体   繁体   English

如何在Mac上安装旧版JDK?

[英]How do I install older version of JDK on Mac?

I need to install JDK 5 for testing Amazon mechanical turk APIs (which is not fully compatible with JDK 6). 我需要安装JDK 5来测试亚马逊机械特克斯API(与JDK 6不完全兼容)。 On Apple's website, I can only find the latest JDK. 在Apple的网站上,我只能找到最新的JDK。 Is there a way to get older versions of JDKs for Mac? 有没有办法让Mac的旧版本的JDK?

You can compile against the 1.5 jdk with settings in javac. 您可以使用javac中的设置针对1.5 jdk进行编译。

In your case : 在你的情况下:

 javac -source 1.5 -target 1.5

You can even set this in your IDE. 您甚至可以在IDE中进行设置。 Or you can do this with maven and the maven.compile.target and maven.compile.properties 或者您可以使用maven和maven.compile.target以及maven.compile.properties来完成此maven.compile.properties


-source release - 资源发布

Specifies the version of source code accepted. 指定接受的源代码版本。 The following values for release are allowed: 允许以下释放值:

[...] [...]

  • 1.5 1.5
    The compiler accepts code containing generics and other language features introduced in JDK 5. 编译器接受包含JDK 5中引入的泛型和其他语言功能的代码。

[...] [...]


-target version - 目标版本

Generate class files that target a specified version of the VM. 生成以指定版本的VM为目标的类文件。 Class files will run on the specified target and on later versions, but not on earlier versions of the VM. 类文件将在指定的目标和更高版本上运行,但不会在早期版本的VM上运行。 Valid targets are 1.1 1.2 1.3 1.4 1.5 (also 5 ) and 1.6 (also 6 ). 有效目标是1.1 1.2 1.3 1.4 1.5 (也是5 )和1.6 (也是6 )。
The default for -target depends on the value of -source : -target的默认值取决于-source的值:

  • If -source is not specified, the value of -target is 1.6 如果未指定-source ,则-target的值为1.6
  • If -source is 1.2 , the value of -target is 1.4 如果-source1.2 ,则-target的值为1.4
  • If -source is 1.3 , the value of -target is 1.4 如果-source1.3 ,则-target的值为1.4

For all other values of -source, the value of -target is the value of -source . 对于-source的所有其他值, -target的值是-source的值。


Resources : 资源:

Yes, this is the problem with macs. 是的,这是macs的问题。
If you do backups, then you can just copy old folders containing jdk 5 from backup disk back to your machine. 如果进行备份,则只需将包含jdk 5的旧文件夹从备份磁盘复制回计算机即可。 Worked for me. 为我工作。

use 采用

-target 1.5 - 目标1.5

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM