Simple function to switch between multiple Java versions

Recently we have started upgrade our java applications to start using Java 8.  Wanted to quick and easy way to switch between different versions of Java.

If I was using a debian variant of Linux(Ubuntu/Mint etc.), I could have used

sudo update-alternatives --config java

But am using a Mac, hence wrote this …

jvm() {
 export JAVA_HOME=`/usr/libexec/java_home -v "$1"`
 java -version
Advertisements
This entry was posted in command, java, mavericks, tool, utility, version, yosemite. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s