3fgssq
Last Updated: February 25, 2016
·
577
· junior-ales
0457965b9998d626e610a6279c852987

How to check (and change) your default JDK with one command

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:

Picture

  • You want to know where is installed your JDK6:

Picture

  • You want to know where is installed your JDK7:

Picture

  • You want the list of installed JDK:

Picture

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:

Picture

Picture

Have fun!


source: http://blog.hgomez.net/blog/2012/07/20/understanding-java-from-command-line-on-osx/

Say Thanks
Respond
Filed Under

Awesome Job

B6c77ad0 c95b 11e7 8263 8f89080b8db6
Ruby Developer Backend
·
Austria (Vienna or Linz)
·
Full Time