RE: helper to switch java versions

Do you guys have any tips on being able to switch between java versions,
namely 1.6 to 1.7?

I remember seeing a nice bash script that did this, it actually listed
all
the javaverions installed and let you choose which one to be active.

if you’re on OS X there’s java_home:

JAVA_HOME=$(/usr/libexec/java_home -v 1.6)

run /usr/libexec/java_home -V and it lists all installed versions.
besides filtering on version (with -v as above) you can filter 32 bit
vs.
64 bit and you can even use it to execute a specific version of java:

/usr/libexec/java_home -v 1.6 --exec java -version

T#

Also for OS X is “pickjdk”, a bit richer than java_home:

This is what I use, and I think it’s the one the OP was looking for
(presents a menu, etc).

  • Charlie

Hah…yeah perhaps it could be Ruby, but I don’t know if Ruby can
manipulate calling shell’s env :slight_smile:

Anyway, there it is!

  • Charlie

… but I don’t know if Ruby can manipulate calling shell’s env :slight_smile:

Oh year, there’s that. :wink:

  • Keith

On Thu, Jun 27, 2013 at 4:23 PM, Charles Oliver N.

Charlie -

What weird language is that in, and how come it’s not Ruby? :slight_smile:

I respect the ability to write nontrivial shell scripts, but boy, that
code
is ugly! :wink:

In any case, thank you, Nick, for writing it.

  • Keith

On Thu, Jun 27, 2013 at 3:33 PM, Charles Oliver N.