Search code examples
terminalinstallationjava-7osx-server

How can I install JDK 7 on Mac OS 10.7 only with command line?


I wish to install a JDK 7 on a XServe (mac server) with a Mac OS 10.7, which has no output device. The only way to connect to it is using a ssh tunnel and doing everything with the terminal (forget about VNC, there is no way to use it in my environment).

I first mounted the dmg of the JDK:

hdiutil mount jdk-7u60-macosx-x64.dmg 

Then, I tried using the installer command, but with no success

sudo installer -pkg /Volumes/JDK\ 7\ Update\ 60/JDK\ 7\ Update\ 60.pkg -target anywhere

This outputs:

installer: Error trying to locate volume at anywhere

I tried using different path for the target (/Volumes/anywhere, anywhere, /Volumes/myVolume/anywhere), without better result.

Any idea ?


Solution

  • I understood my mistake. I first needed to use the dominfo command to get the possible targets

    sudo installer -pkg /Volumes/JDK\ 7\ Update\ 60/JDK\ 7\ Update\ 60.pkg  -dominfo
    

    which gave me a list of domains. I had then to use one of these domains:

    sudo installer -pkg /Volumes/JDK\ 7\ Update\ 60/JDK\ 7\ Update\ 60.pkg -target the_chosen_domain