Export Java_home Globally Macos Not Onyl For Session

The Java JDK install on MacOS has some interesting platform specific utilities, like

Sep 09, 2015  open.bashprofile file in your home directory or create if it doesn't already exists. Make an entry of Javahome=/path/to/java/home in file. If you do it through the. Not quite: javahome is an executable. When you run it, it prints the path to the Java installation to stdout. The $ is bash functionality that executes a command and returns what was printed to stdout. The Java JDK install on MacOS has some interesting platform specific utilities, like /usr/libexec/javahome which tells you which Java version you’re currently using and where it’s inst.

which tells you which Java version you’re currently using and where it’s installed. I have Java 9 currently installed and it tells me:

If you have multiple version installed, adding -V will list all the versions and where they’re installed:

The next logical question from here would be ‘how do I switch versions’? If you set your $PATH in a .profile or similar approach, you can eval java_home to add the current version to your path, but a neat trick discussed in one of the answers here (thanks to this SO user for this tip) uses the -v option to allow you to switch versions. Adding a couple of aliases to your .profile like this:

… and you’ve got a quick shortcut to switching between different versions.

Mac Os High Sierra Download

Java_home

Export Java_home Globally Macos Not Onyl For Session 2016

I don’t remember where I first found this line of code, but if you put it in your Mac OS X ~/.bash_profile file, it’s an easy way to set your Mac Java version:

I can confirm this works with the Bash shell on Mac OS X 10.10. When I run the java -version command after opening a new Mac Terminal window, the output is 1.8.0_25.

Mac Os Download

A slightly more difficult way to set your Mac Java version is to look under the /Library/Java/JavaVirtualMachines directory to see which versions are installed, and then manually set the version.