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?
If you already have Java for OS X from Apple installed, then installing a JRE from Oracle will not update java -version symlinks. These steps must be done manually.
Note: Use the following command to determine the version of a not-linked-for-shell use Java
- '/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/java' -version
Changing the Java Symlinks
- 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/
- Open Terminal.app
- Type in the following command:
- java -version
- If the version number looks like 1.7.X_XX OR 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.
- If the version number does not does not look like 1.7.X_XX OR 1.8.X_XX, then an Oracle version of Java is not set as the default runtime environment. Proceed to the next step.
- Type in the following two commands:
- 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
- Type in the following command:
- java -version
- It should now indicate that Java 7 or Java 8 is the default runtime environment.
For more information, see https://gist.github.com/johan/10590467
If you need further assistance, please contact IGPP NetOps.