Java 6 For OSX 10.15 Catalina

Those of us who work with Legacy versions of Java are familiar with the dance of installing OS upgrades and reinstalling Apple Java 6. Well this time around it gives a message that a newer version is installed and won’t let you proceed with install. Of course we can’t hang with that so here’s a nice little bash script solution…this will download the file from Apple CDN, mount it, modify some booleans using sed and then drop a package on your desktop that will then let you install with out the OS version check.

cd ~/Downloads
rm -f javaforosx.dmg
hdiutil mount ~/Downloads/javaforosx.dmg
pkgutil --expand "/Volumes/Java for macOS 2017-001/JavaForOSX.pkg" ~/tmp
hdiutil unmount "/Volumes/Java for macOS 2017-001"
sed -i '' 's/return false/return true/g' ~/tmp/Distribution
pkgutil --flatten ~/tmp ~/Desktop/Java.pkg
rm -rf ~/tmp