Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

'RVM-like' tool for Java

I am looking for a tool that would let me switch the running Java implementation, like Ruby's RVM (or RBENV). I am aware that Debian systems provide the alternatives mechanism, and that I can set JAVA_HOME manually.

However, I'd like something more automated if possible. If it could fetch JDKs that would be even better, but not necessary.

I've searched but didn't see anything like it. My guess the Java ecosystem got used to having this functionality in an IDE.

Edit: Changing PATH and JAVA_HOME seems to work fine. It could be trivially automated.

like image 333
Stephen Eilert Avatar asked Apr 20 '12 03:04

Stephen Eilert


People also ask

What is NVM in Java?

Byte-addressable, non-volatile memory (NVM) is emerging as a revolutionary memory technology that provides persis- tency, near-DRAM performance, and scalable capacity. To facilitate its use, many NVM programming models have been proposed.

How do I change my Java version?

In the Java Control Panel, click on the Java tab. Verify that the latest Java Runtime version is enabled by checking the Enabled box. Click OK in Java Control Panel window to confirm changes and close the window. Try to run same applet and verify it is now running using latest version of Java installed in your system.


2 Answers

There's jenv, based on Ruby's RVM.

You have to go through some manual steps to add new Java versions†, but once they're in you can switch between them using jenv use java $version. It also handles installing Java applications against specific Java versions.

There's also another tool that I haven't used, confusingly also named jenv but based on Ruby's rbenv instead.

† The hassle adding Java versions appears to be due to Oracle, perhaps licensing issues, and seems to apply to both tools.

like image 102
Dan Midwood Avatar answered Oct 10 '22 09:10

Dan Midwood


I think there is no such tool. Every platform has hits own system. Debian/Ubuntu, RedHat/CentOS and SLE/OpenSUSE ( probably some other distributions as well) use the alternative mechanism. Mac OSX has its own buildin switching mechanism to change the current used JVM.

I have to maintain a lot of developer workstations and servers. All *nix based (OSX, Linux, Solaris) and used to install all JVMs in a directory and create a symlink CURRENT to the Version that should be used. The JAVA_HOME and PATH variable pointing to this CURRENT symlink. If Ia want to use another version only haf to move the CURRENT symlink. No further actions are necessary.

Unfortunately this approach does not work for Windows based systems.

like image 24
magomi Avatar answered Oct 10 '22 11:10

magomi