Install dmg package on MAC OS from Terminal

user3472065 picture user3472065 · Apr 8, 2014 · Viewed 26.3k times · Source

I would like to install the dmg java package in my MAC OS through the terminal

I tried using this command:

sudo installer -package jdk-7u51-macos-x64.dmg -target /

But I receive this error:

installer: Error the package path specified was invalid: 'jdk-7u51-macos-x64.dmg' 

Answer

Mateusz Szlosek picture Mateusz Szlosek · Apr 8, 2014

Try this:

MOUNTDIR=$(echo `hdiutil mount jdk-7u51-macos-x64.dmg | tail -1 \
| awk '{$1=$2=""; print $0}'` | xargs -0 echo) \
&& sudo installer -pkg "${MOUNTDIR}/"*.pkg -target /