Friday, March 25, 2016

Installing Java 8 on OSX

Download instructions
http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html

https://docs.oracle.com/javase/8/docs/technotes/guides/install/mac_jdk.html#A1096855

Find the Java Control Panel on Mac

Launch the Java Control Panel on Mac OS X (10.7.3 and above)
  1. Click on Apple icon on upper left of screen.
  2. Go to System Preferences
  3. Click on the Java icon to access the Java Control Panel.

Improved how to switch Java versions using BASH:


  1. Find the Java version that is required:
    1.  /usr/libexec/java_home  -V
  2. Run the java.sh script below:
    1. java.sh
    2. Example:
$ /usr/libexec/java_home  -V
Matching Java Virtual Machines (3):
    1.8.0_77, x86_64: "Java SE 8" /Library/Java/JavaVirtualMachines/jdk1.8.0_77.jdk/Contents/Home
    1.8.0_60, x86_64: "Java SE 8" /Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home
    1.7.0_71, x86_64: "Java SE 7" /Library/Java/JavaVirtualMachines/jdk1.7.0_71.jdk/Contents/Home

/Library/Java/JavaVirtualMachines/jdk1.8.0_77.jdk/Contents/Home

$ setjdk 1.8.0_77


https://github.com/StevenACoffman/dotfiles/blob/master/bin/shell/functions/java.sh

The Java version switcher scripts use java_home program.
http://docs.oracle.com/javase/8/docs/technotes/guides/install/mac_jdk.html#A1096903

$ /usr/libexec/java_home  --help
Usage: java_home [options...]
    Returns the path to a Java home directory from the current user's settings.

Options:
    [-v/--version   ]       Filter Java versions in the "JVMVersion" form 1.X(+ or *).
    [-a/--arch      ]  Filter JVMs matching architecture (i386, x86_64, etc).
    [-d/--datamodel ]     Filter JVMs capable of -d32 or -d64
    [-t/--task      ]          Use the JVM list for a specific task (Applets, WebStart, BundledApp, JNI, or CommandLine)
    [-F/--failfast]                  Fail when filters return no JVMs, do not continue with default.
    [   --exec      ...]   Execute the $JAVA_HOME/bin/ with the remaining arguments.
    [-R/--request]                   Request installation of a Java Runtime if not installed.
    [-X/--xml]                       Print full JVM list and additional data as XML plist.
    [-V/--verbose]                   Print full JVM list with architectures.
    [-h/--help]                      This usage information.

$ /usr/libexec/java_home  -
/Library/Java/JavaVirtualMachines/jdk1.8.0_77.jdk/Contents/Home

$ /usr/libexec/java_home  -V
Matching Java Virtual Machines (3):
    1.8.0_77, x86_64: "Java SE 8" /Library/Java/JavaVirtualMachines/jdk1.8.0_77.jdk/Contents/Home
    1.8.0_60, x86_64: "Java SE 8" /Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home
    1.7.0_71, x86_64: "Java SE 7" /Library/Java/JavaVirtualMachines/jdk1.7.0_71.jdk/Contents/Home