How to Switch Java Version Mac OS X 10.10 Yosemite Easy Guide

December 17, 2014 | By the+gnu+linux+evangelist.

Mac OS X Switching Java Version on Shell

The Unix Tutorial shows you Step-by-Step How to Easy Switching on Terminal Bash Shell a Java Multi-Version Installation for macOS 10.10 Yosemite Unix/BSD.

The Tutorial Include also Links on How to Download and Install Oracle Official Java Development Kit 7/8 for macOS.

Mac OS X How to Switch Java Version Command Line - Featured
  1. Open a Command Line Terminal Window
    (Press “Enter” to Execute Commands)

    Switch Java on macOS 10.10 Yosemite on Terminal - Open Terminal

    In case first see: Terminal QuickStart Guide.

  2. Edit the Bash Shell Config Environment.

    nano $HOME/.bashrc

    Copy & Paste inside this Function:

    /nalias java_ls='/usr/libexec/java_home -V 2>&1 | grep -E "\d.\d.\d[,_]" | cut -d , -f 1 | colrm 1 4 | grep -v Home'
    
    function java_use() {/nexport JAVA_HOME=$(/usr/libexec/java_home -v $1)/nexport PATH=$JAVA_HOME/bin:$PATH
    java -version
    }
    

    Ctrl+x to Save & Exit from nano Editor :)

  3. Load the New Environment.

    bash
  4. How to Install Oracle Java JDK 8+ on macOS

    Installing Oracle JDK for macOS
  5. Then to Easy Switch the Java Version.

    java_use 1.[x]

    Example:

    java_use 1.6

QuickChic Theme • Powered by WordPress