Java 2 Standard Edition SDK (J2SE SDK)

To develop desktop Java applications or if you need a Java Runtime Environment (JRE) you can use the Java 2 Standard Edition Software Development Kit (J2SE SDK).

The latest J2SE SDK version can be downloaded from:

Installing Java 1.8.0 on macOS


Operating system used
macOS (Sierra) 10.12.3

Software prerequisites

  1. To install Java, type: brew cask install java

  2. To check if Java is installed correctly, open a terminal and type: java -version
    You should see:
    java version "1.8.0_121"
    Java(TM) SE Runtime Environment (build 1.8.0_121-b13)
    Java HotSpot(TM) 64-Bit Server VM (build 25.121-b13, mixed mode)

  3. Show all java versions installed.
    Type: /usr/libexec/java_home -V

    You should see:
    1.8.0_121, x86_64: "Java SE 8" /Library/Java/JavaVirtualMachines/jdk1.8.0_121.jdk/Contents/Home

    More information about the java_home tool.
    Type: /usr/libexec/java_home -help

  4. To use a particular java version installed.
    Add the following line in your .bash_profile file.
    export JAVA_HOME="$(/usr/libexec/java_home -v 1.8)"

    If you have only one version installed, then you can omit the version:
    export JAVA_HOME="$(/usr/libexec/java_home)"

    If you have multiple versions installed, for example (these versions does not exists!):
    and you want to use version 1.8.3_111 then you need to be more specific when specifying the version:
    export JAVA_HOME="$(/usr/libexec/java_home -v 1.8.3)"

  5. To check the JAVA_HOME path.
    Type: echo $JAVA_HOME