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.

#!/bin/bash
cd ~/Downloads
rm -f javaforosx.dmg
wget https://updates.cdn-apple.com/2018/macos/031-33898-20171026-7a797e9e-b8de-11e7-b1fe-c14fbda7e146/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