Posts

Showing posts from November, 2014

Easily changing java versions in OSX

In OSX, they've frankly done a pretty good job of enabling multiple versions of java at the same time, but just as frankly it's somewhat obscure and inconvenient to manage multiple versions. It's not mind bogglingly difficult but for us oldsters who are lazy, I created a convenient way to switch versions inspired by (though nowhere nearly as awesome as) rvm for ruby. Download all of the versions of java you want to use from the appropriate location java 1.6 , java 7 , or java 8 . (you need at least one to start with) Add the following lines to ~/.bash_profile jvm() { export JAVA_HOME=`/usr/libexec/java_home -v "$1"` java -version } Either source .bash_profile by typing ". ~/.bash_profile" or simply close your terminal and relaunch At this point you can change versions of java by typing: jvm 1.6* or jvm 1.7* Yes, there's more to it, refer to java_home for more version matching options, and it could be way more awesome, but this