The last time this kind of thing bit me I was inadvertently installing the run-time Java (which is what Apple usually provides a link to) on my server, not the full Java SDK (which has the compilers and stuff you need to do developmentn).
To entirely use a (bash) shell to install e.g. I was trying to install from the command line but could not find a pkg installer online any more.
I saw that JavaAppletPlugin.pkg in the DMG but thought it was not what I wanted because the name is misleading. I tried using installer the way you did but it hung just like the GUI version. I forced quit it and used the options I had used before with pkg installers and this worked: installer -verboseR -dumplog -pkg '/Volumes/Java 8 Update 131/Java 8 Update 131.app/Contents/Resources/JavaAppletPlugin.pkg' -target / -store The -store emulates installation from the Mac App Store. – Jul 5 '17 at 21:44.