Question or issue on macOS:
I’ve got to write some code for a legacy application that is still running JDK 1.5. Unfortunately, it looks like OS X doesn’t actually have a 1.5 JDK installed; it just links to 1.6:
If you have not yet installed Apple's Java OS X 2012-006 update, then you are still using a version of Apple Java 6 that includes the plug-in and the Java Preferences application. See Notes for Users of macOS That Include the Apple Java 6 Plug-in. This answer is an attempt to address: how to control java version system-wide (not just in currently running shell) when several versions of JDK are installed for development purposes on macOS El Capitan or newer (Sierra, High Sierra, Mojave).As far as I can tell, none of the current answers do that (.). As a developer, I use several JDKs, and I want to switch from one to the other easily. Download Java for OS X 2017-001 Java for macOS 2017-001 installs the legacy Java 6 runtime for macOS 10.13 High Sierra, macOS 10.12 Sierra, macOS 10.11 El Capitan, macOS 10.10 Yosemite, macOS 10.9 Mavericks, macOS 10.8 Mountain Lion, and macOS 10.7 Lion.
It sounds like from http://developer.apple.com/java/faq/ that Java is part of the OS update…I’m on Mac OS X v10.6.3 (Snow Leopard). Is there a way to get an actual 1.5 JDK installed on this OS version?
Or do I need to try and find an old version of OS X before I can do this work?
How to solve this problem?
Solution no. 1:
If you’re writing code in Eclipse or potentially some other IDE, you should be able to configure it to target 1.5 compliance.
If you are using javac directly, you could try the -source 1.5
and/or -target 1.5
javac options, which may be sufficient for what you’re doing? The 1.6 JDK should be able to produce 1.5-compliant code.
Solution no. 2:
Have a look at http://wiki.oneswarm.org/index.php/OS_X_10.6_Snow_Leopard on how to get and install 1.4 and 1.5 JDKs on Snow Leopard.
Also bear in mind that whenever you run Software Update and a JDK update is installed, you will need to “fix” the symlinks to the 1.4 and 1.5 JDKs.
UPDATE: as a side note, for those developing with several JDKs on OS X, have a look at this handy little utility to switch JDK from the command line: setjdk.
Solution no. 3:
There are really two problems here:
- Installing an old version of Java, and keeping Software Update from removing it.
- Telling applications that require the older version where to find it, while letting everything else benefit from the latest version.
I don’t have anything to add (yet) to what has already been written about installing an old version of Java, however, according to this post from Mike Swingler, Java Runtime Engineer at Apple:
Nobody can or should should be changing symlinks in /System/Library/ Frameworks/JavaVM.framework except for Apple software updates (and we are loath to do so, because it inevitably breaks someone)
In other words, updating the Operating System’s links to the old copy of Java is a questionable practice, as it forces every Java application on the system to use the old Java version.
The right way is to set JAVA_HOME
to the correct version of Java on an as-needed basis. You can do this by executing /usr/libexec/java_home
to get the path to a specific version. For example, to get the path to a 1.5 version:
/usr/libexec/java_home --version 1.5
Solution no. 4:
You don’t need a copy of Java 1.5 in order to develop for it; Java 1.6 is backwards-compatible with Java 1.5, so anything that would work on 1.5 will work on 1.6. The -source
and -target
flags may be of use in order to ensure that everything works on 1.5. That said, this article will explain how to get a copy of Java 1.5 on Snow Leopard. Be aware, though, that it could potentially trash/harm your system.
Solution no. 5:
Thanks this works great: http://wiki.oneswarm.org/index.php/OS_X_10.6_Snow_Leopard
Java Jdk 1.6 For Mac Os X 10 11
Strangely, you must follow the renaming steps in the instructions, where you mod the symlinks for 1.5 and 1.5.0 to the actual leopard Java 1.5 – if you don’t do that and just try to run the java binary, you get a bus error!
In any case, thanks to these steps I now have an actual Java 5 JDK to compile and run against in Eclipse, which saves me lots of trouble. For one thing, I can find and remove references to Java 1.6-only methods instantly. It’s great. Before these would only show up in QA, or even worse, when one of the few customers still on Java 5 tried to run our program. Which was. Bad.
This is why “supporting” JDK5 while actually just pointing symlinks to Java 6 is not good enough for development.
Solution no. 6:
The absolutely easiest way is to use this script by Brice Dutheil. Save the script, download the dmg from Apple (the script will tell you the URI), and run the script. Voila!
Solution no. 7:
Although the -source and -target flags can be used, they don’t always produce code which works on all older JREs. I’ve definitely had occasions where trying to back-compile to an older spec produced code which worked fine for some users, but wouldn’t run on others. To be really sure that everyone using a 1.5 or 1.4 JRE can run your code, you should probably do your production builds with a 1.5 or 1.4 JDK.
I found these instructions very helpful on getting a “real” 1.5 and 1.4 JDK installed under snow leopard:
http://codethought.com/blog/?p=233
Solution no. 8:
You need a older version of OS X for that.
Hope this helps!
Question or issue on macOS:
Java Jdk 1.6 For Mac Os Xos X
I’ve installed on my iMac (Mac OS X 10.6.6) the Java update which contains the version 1.6.0_24 of the jdk. I think this update has changed the directory structure of the jdk, so now I’m not able to configure it on eclipse.
Before the update my eclipse were linked to this path: /System/Library/Frameworks/JavaVM.Framework/Versions/Current/Home which actually seems wrong.
Now I’m not able to link my eclipse to the jdk. Maybe this is the right path: /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home, but 1.6.0.jdk isn’t a directory, so I’m not able to choose it in eclipse.
Has anyone experienced this problem? How can I solve it?
How to solve this problem?
Solution no. 1:
For me following jdk link is working fine on Eclipse:
Solution no. 2:
It was my fault. I had also a jdk 1.5 manually installed and the update moved it away.
Probably I made a mistake restoring my jdk-1.5 to its correct location.
To solve my issue I just had to restore the symbolic links /System/Library/Frameworks/JavaVM.Framework/Versions/CurrentJDK
, which has to point to /System/Library/Frameworks/JavaVM.Framework/Version
.
Solution no. 3:
the follow directory works:
without “System”
Solution no. 4:
Execute /usr/libexec/java_home on the terminal shell.
It will display a list of all your installed JDKs
Solution no. 5:
On MacOSX 10.10, jdk 1.8 with IntelliJ, I use:
Solution no. 6:
I was missing CurrentJDK
folder as well, but I’m running Mac OS El Capitan.
In El Capitan it’s not possible to modify the folder /System/Library/Frameworks/JavaVM.framework/Versions
, since it is under the /System
folder and SIP is protecting it (you can disable SIP, but I do not recommend), a custom CurrentJDK
soft link is not allowed.
I got some legacy software which was searching for CurrentJDK
, and there was no way to update the path. To solve it I had to install Java for OS X 2015-001 provided by apple (it’s Java 1.6), which fixed the Versions
subfolder structure by pointing to the old Java 1.6. Not the best, but it fixed my error!