To begin with, this tip is to Java developers using Mac OS (if you use linux check this tip).
If every time you need information about your installed JDKs, you feel hammered by environment variables, exports, bash_profiles and all those things, hell yeah this tip will be a relief to your head.
There's an utilitarian called java_home on OSX located at
/usr/libexec that summarizes all your machine Java Preferences. How it works? Look at that:
- You want to know your default JDK:
- You want to know where is installed your JDK6:
- You want to know where is installed your JDK7:
- You want the list of installed JDK:
If you run the javahome command with an argument of a non-installed JDK (e.g. I don't have a JDK8 installed but I run `/usr/libexec/javahome -v 1.8`) the outcome will be the path of your default JDK.
Having that in mind, changing the current JDK becomes easy as follow: