Disregard... as soon as I posted this, I found a script that appears to work.
I know this has been discussed several times, but I wanted to throw my 2 cents in... I wrote a script to install and update Java. This version only does the JRE, although I'm sure you could expand it to do the JDK also.
#!/bin/sh
# Get the latest version of Java
javaver=`curl -s http://javadl-esd-secure.oracle.com/update/baseline.version | grep 1.8.0_`
minorver=`echo $javaver | grep -o '...$'`
# Get build number (counting down from 20), since I can't find anywhere that Oracle publishes this in an easily-findable place
b=20
while [ $b -gt 1 ] ; do
echo "Build number $b"
filename="jre-8i$minorver-macosx-x64.dmg"
curl -j -k -L -H "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u$minorver-b$b/96a7b8442fe848ef90c96a2fad6ed6d1/jre-8u$minorver-macosx-x64.dmg > $filename
# Check the file size of the download
minsize="500000"
filesize=$(wc -c <"$filename")
# If the file is larger than 500kb, assume it's the real dmg
if [ $filesize -ge $minsize ]; then
echo "Build number: $b succeeded"
break
fi
b=`expr $b - 1`
done
# Attach the DMG
hdiutil attach jre-8i$minorver-macosx-x64.dmg
# Install
sudo installer -pkg /Volumes/Java 8 Update $minorver/Java 8 Update $minorver.app/Contents/Resources/JavaAppletPlugin.pkg -target /
# Remove DMG
rm jre-8i$minorver-macosx-x64.dmg
# Unmount DMG
diskutil umount /Volumes/Java 8 Update $minorver
I'm positive it can be dramatically improved, but even though there are dozens of threads about it, I couldn't find a script that worked for me. So far, it's worked on a couple of my test systems, both without Java installed at all, and with an older version (1.8.0_131). It successfully installed/upgraded both.