I need to install Java from command line. This is what I am trying:
hdiutil attach javaforosx.dmg
cd /Volumes/Java\ for\ OS\ X\ 2015-001/
sudo installer -pkg JavaForOSX.pkg -target "/"
sudo hdiutil detach hdiutil detach /Volumes/Java\ for\ OS\ X\ 2015-001/
It fails at the last step, with the error message:
hdiutil: couldn't unmount "disk2" - Resource busy
What more, if I now go to my desktop and manually try to eject the disk image that is showing up in regards to Java (right click -> Eject) it says I cannot eject it, the terminal is using it. I have to close the terminal and only then I am able to eject the disk.
How do I do it correctly from command line?