在OSX 10.10 Yosemite中安装JDK 1.5

时间:2015-04-09 10:04:09

标签: java eclipse macos osx-yosemite jdk1.5

我使用OS X Yosemite(10.10.2),我必须使用JDK 1.5进行遗留应用程序开发。我发现this帖子引用this脚本在Lion和Mavericks中安装JDK 4,5,6。在评论中我发现了这两行

/usr/libexec/PlistBuddy -c "Set :JavaVM:JVMMaximumFrameworkVersion 14.*.*" ./Resources/Info.plist
/usr/libexec/PlistBuddy -c "Set :JavaVM:JVMMaximumSystemVersion "$osx_version".*" ./Resources/Info.plist

必须由

更改
/usr/libexec/PlistBuddy -c "Delete :JavaVM:JVMMaximumFrameworkVersion" ./Resources/Info.plist
/usr/libexec/PlistBuddy -c "Delete :JavaVM:JVMMaximumSystemVersion" ./Resources/Info.plist

实现与优胜美地的兼容。我运行了这个脚本,这是我的/System/Library/Frameworks/JavaVM.framework/Versions目录

的内容
lrwxr-xr-x  1 root  wheel   10  8 apr 14:36 1.4 -> CurrentJDK
lrwxr-xr-x  1 root  wheel   10  8 apr 14:36 1.4.2 -> CurrentJDK
lrwxr-xr-x  1 root  wheel   10  9 apr 11:01 1.5 -> ./1.5.0_30
lrwxr-xr-x  1 root  wheel   10  9 apr 11:01 1.5.0 -> ./1.5.0_30
drwxr-xr-x  9 root  wheel  306  9 apr 11:01 1.5.0_30
lrwxr-xr-x  1 root  wheel   10  8 apr 14:36 1.6 -> CurrentJDK
lrwxr-xr-x  1 root  wheel   10  8 apr 14:36 1.6.0 -> CurrentJDK
drwxr-xr-x  7 root  wheel  238  8 apr 14:36 A
lrwxr-xr-x  1 root  wheel    1  8 apr 14:36 Current -> A

在Eclipse偏好 Java->已安装的JRE->执行环境中,没有任何JRE 1.5

enter image description here

可能这就是我无法在Java 5中构建项目的原因,因为我收到了错误:

Build path specifies execution environment J2SE-1.5. There are no JREs installed in the workspace that are strictly compatible with this environment.

在Eclipse首选项中已安装的JRE - JSE-1.5引用正确的路径

enter image description here

在项目首选项中 Java构建路径包含 J2SE-1.5

enter image description here

项目首选项中的

Java编译器也正确设置。

enter image description here

这是/System/Library/Frameworks/JavaVM.framework/Versions/1.5.0_30目录

的内容

enter image description here

此帖子引用我的previous帖子。

1 个答案:

答案 0 :(得分:1)

我认为您问题的解决方案可能是in this question

Eclipse是一个功能强大的IDE,因此可以告诉1.6 / 1.7 / 1.8 JRE如同1.5 JRE一样运行。我不熟悉使用它,但它看起来比下载完全不同的JDK容易得多。

要更改编译器合规性级别,请转到Project Settings -> Java Compiler

Java Compiler Settings

取消Use compliance from execution environment并确保勾选Use default compliance settings,并将其旁边的框设置为1.5

然后您可以改回使用JDK 1.7。

请告诉我这是否有效,因为我可以发布一个答案,为您安装一个新的JRE,如果这没有帮助。