Mac And Java 9 – How to set JDK 9 as default

Objective: 

This page will show step by step to set JDK 9 as default JVM on MAC.

Pre-requisites

  1. Java 9 should have installed. If not follow the instruction given on oracle website.

Steps:

  1. Get installed Java: Open terminal and execute-

    /usr/libexec/java_home -V   [<——-  side note : this is capital v]

    Each row first column is the java version. Copy it against java 9 version.

  2. Set default Java: execute-

    /usr/libexec/java_home -v {Put_Copied_Version} –exec javac -version[<——-  side note : here is small v]

  3. Set environment variable: Update bash profile or terminal as follows

     export JAVA_HOME=`/usr/libexec/java_home -v {Put_Copied_Version}`

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s