I am using OS X Yosemite (10.10.2) and I have to use JDK 1.5 to develop legacy applications. I found this post that references this script for installing JDK 4, 5,6 in Leo and Mavericks. In the comments I found 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
need to change to
/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 the contents of my directory/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
In Eclipse settings Java-> Installed JREs-> Runtime is missing JRE 1.5

and probably for this very reason I canโt 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 Settings Installed JRE - JSE-1.5 refers to the correct path

Java J2SE-1.5

Java .

/System/Library/Frameworks/JavaVM.framework/Versions/1.5.0_30

.