Install JDK 1.5 in OSX 10.10 Yosemite

喜你入骨 提交于 2019-12-30 11:21:51

问题


I use OS X Yosemite (10.10.2) and I have to use JDK 1.5 for legacy application development. I found this post which refers to this script to install JDK 4,5,6 in Lion and Mavericks. In comments I found this two lines

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

have to be changed by

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

to achieve compatibility with Yosemite. I ran this script and this is content of my /System/Library/Frameworks/JavaVM.framework/Versions directory

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

In Eclipse preferences Java->Installed JREs->Execution Environments, there is not any JRE 1.5

and probably this is the reason why I cannot build projects in Java 5, because I get errors:

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

In Eclipse preferences Installed JREs - JSE-1.5 refers to correct path

In project preferences Java Build Path contains J2SE-1.5

and Java Compiler in project preferences is set correctly as well.

This is content of /System/Library/Frameworks/JavaVM.framework/Versions/1.5.0_30 directory

This thread refers to my previous post.


回答1:


I think the solution to your problem might be in this question.

Eclipse is a powerful IDE, and as such can tell a 1.6/1.7/1.8 JRE to run as if it was a 1.5 JRE. I am not familiar with using this, but it looks a lot easier than downloading an entirely different JDK.

To change the compiler compliance level, go to your Project Settings -> Java Compiler

Untick Use compliance from execution environment and ensure that Use default compliance settings is ticked, and that the box alongside that is set to 1.5.

Then you can change back to using your JDK 1.7.

Please let me know if this worked, as I can post an answer that walks through installing a new JRE for you, if this hasn't helped.



来源:https://stackoverflow.com/questions/29535500/install-jdk-1-5-in-osx-10-10-yosemite

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!