OS X: Extract JDK to folder, without running installer
On Linux, I'm used to downloading the JDK as a tarball, extracting it, and setting PATH and JAVA_HOME accordingly. This makes it super-easy to switch Java versions, run multiple older versions, and so on.
I just got a Macbook Air, and the only option for installing Java there, is a .dmg file with a .pkg installer. No wireless. Less space than a nomad. Lame.
How to extract to a folder
Here, a numbered list, to make it easy for you.
- Download the installer .dmg files. They contain the good stuff.
- Mount the .dmg and copy the .pkg file to somewhere
- Open a terminal and cd to the folder you copied the .pkg file into
pkgutil --expand JDK\ 7\ Update\ 60.pkg JDK7u60- extract pkg file to folder
cd JDK7u60/- move to the extracted pkg
cd jdk17060.pkg/- there's a folder with the version number ending with .pkg (but it's just a folder), go there
open Payload- this is a gzipped "ASCII cpio archive (pre-SVR4 or odc)", according to
file. The "open" command will extract it using the Archive Utility app.
- Done! Now you just need to copy the files.
cp Contents/Home ~/local/jdk_1.7u60
No installer was ever executed. No auto updater will be installed. No global PATH will get whatever "java" you already had overwritten.
Questions or comments?