java - 在 OSX 10.10 Yosemite 中安装 JDK 1.5

标签 java eclipse macos osx-yosemite java-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->Installed JREs->Execution Environments 中,没有任何 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 首选项中 Installed JREs - JSE-1.5 指的是正确的路径

enter image description here

在项目首选项中Java Build Path 包含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发布。

最佳答案

我认为您的问题的解决方案可能是 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。

关于java - 在 OSX 10.10 Yosemite 中安装 JDK 1.5,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29535500/

相关文章:

java - 将不同类中的 BigInteger 写入文件

java - 如何从eclipse的jar写入Jmeter的日志

java - 在 Java 中对数组列表进行排序时无法转换为类错误

java - 如何在保留先前文本的同时输入 HTML JEditorPane?

java - 使用 Eclipse 编译器编译时 LocalVariableTypeTable 中出现奇怪的 "!*"条目

java - 无法访问浏览器异常

java - 在从 java.util.date 转换为 java.sql.date 之前检查空日期

macos - 这个模态界面元素的名称是什么?

swift - 如何将数组 Controller 绑定(bind)到核心数据模型?

macos - 如何从歌曲文件中获取歌曲的歌词