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

December 17th, 2014 by thelinuxevangelist

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 Mac OS X 10.10 Yosemite Unix/BSD.

The Tutorial Include also Links on How-to Download and Install the Oracle Official Java Development Kit 7/8 for Mac OS X.

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 Mac OS X 10.10 Yosemite on Terminal - Open Terminal
  2. Edit the Bash Shell Config Environment

    nano $HOME/.bashrc

    Copy & Paste inside this Function:

    alias 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() {
        export JAVA_HOME=$(/usr/libexec/java_home -v $1)
        export 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 the Oracle Java JDK 7/8 on Mac OS X:

    Install Oracle JDK 7/8 for Mac OS X
  5. Then to Easy Switch the Java Version

    java_use 1.[x]

    Example:

    java_use 1.6


Share on Tumblr

Tags: , , , , , , , , , , , , , , , , , , , , ,


Comments are disabled