Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

How-to: Set Oracle Java as Default Runtime Environment

Desmond Leung updated April 7, 2015 at 1:59 PM



Questions Addressed


  • How do I set the Oracle version of Java as the default runtime environment on my machine? How do I set the Oracle version of Java as the default runtime environment on my machine?
  • Why does running the command "java -version" display the wrong version of Java? Why does running the command "java -version" display the wrong version of Java?

...

  1. Download and install the latest version of Java 7 or Java 8 from Oracle if you have not already done so. https://www.java.com/en/download/
  2. Open Terminal.app Terminal.app
  3. Type in the following command:
      java -version
      1. java -version
      2. If the version number looks like 1.
      1. 7
      1. 7.X_XX
      .X_XX
      1. OR
      1.8.X_XX
      1. 1.8.X_XX, then an Oracle version of Java is already set as the default runtime environment. Do not proceed to the next steps.

        Image Added

      2. If the version number does not does not look like 1.
      1. 7
      1. 7
      .X_XX
      1. .X_XX OR
      1.8.X_XX
      1. 1.8.X_XX, then an Oracle version of Java is not set as the default runtime environment. Proceed to the next step.

        Image Added

    1. Type in the following two commands:
      1. sudo mv /usr/bin/java /usr/bin/java-1.6
      sudo mv /usr/bin/java /usr/bin/java-1.6
      sudo ln -s '/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/java' /usr/bin/java
      1. sudo ln -s '/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/java' /usr/bin/java
    2. Type in the following command:
        java -version
        1. java -version
        2. It should now indicate that Java 7 or Java 8 is the default runtime environment.
      1. java -version java -version
      2. If the version number looks like 1. 1. 7 7 .X_XX .X_XX OR 1.8.X_XX 1.8.X_XX , then an Oracle version of Java is already set as the default runtime environment. Do not proceed to the next steps.
      3. If the version number does not does not look like 1. 1. 7 7 .X_XX .X_XX OR 1.8.X_XX 1.8.X_XX , then an Oracle version of Java is not set as the default runtime environment. Proceed to the next step.

      ...

      1. sudo mv /usr/bin/java /usr/bin/java-1.6 sudo mv /usr/bin/java /usr/bin/java-1.6
      2. sudo ln -s '/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/java' /usr/bin/java sudo ln -s '/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/java' /usr/bin/java
      3. java -version java -version
      4. It should now indicate that Java 7 or Java 8 is the default runtime environment.


      Wiki Markup \\ \\ \\ \\ If you need further assistance, please \[contactIGPPNetOps\] . \\ \\ For more information, see https://gist.github.com/johan/10590467


      If you need further assistance, please contact IGPP NetOps.