Installed Java 7 on Mac OS X but Terminal is still using version 6
Activate Java 7 in Terminal in a flash:
Use these commands directly or append them to ~/.bash_profile
(for Bash) or ~/.zshrc
(for Zsh). This ensures Java 7 is the default in every Terminal session.
Grasping the issue
You've installed Java 7 but the Terminal sticks to the ancient version 6. This occurs due to a mismatch between the system's PATH configuration or a misdirected JAVA_HOME environment variable.
Verify your Java version
Check that the installation of Java 7 was successful:
This lists all JDKs on your system - verify Java 7 is included.
Weed out the old JAVA_HOME
Scan your .bash_profile
or .bashrc
for lines that set the JAVA_HOME variable to the old version:
Remove or update these lines to reflect the correct Java 7 path.
Fixing the environment settings
Now that we've cleaned up, it's time to set the new environment settings.
Cleaning up the .bash_profile
Open ~/.bash_profile
in a text editor and replace any outdated Java paths:
Updating the symbolic links
Our system still thinks /usr/bin/java
is version 6. Let's bring it up to speed:
After, rerun java -version
to confirm Java 7 is now the go-to version.
Covering all bases
Let's ensure Java 7 is properly sown system-wide.
Favor JDK, not JRE
For all the development tools, get the full JDK if you haven't already:
Juggling multiple Java versions
Alternating between Java versions frequently? Here's a swindler's guide to it: use jEnv
:
Setting system preferences
You may find the System Preferences still favoring Java 6. To pick the fresher version, navigate to the Java control panel:
Uncheck the boring old Java 6 and check the shiny new Java 7.
Was this article helpful?