JVM version manager

前端 未结 6 1866
隐瞒了意图╮
隐瞒了意图╮ 2021-02-01 14:06

Is there Ruby Version Manager equivalent for the Java world?

I\'m looking for tool which allow me to easily download and install a new JVMs and switch between them. For

相关标签:
6条回答
  • 2021-02-01 14:26

    The trick is to use update-java-alternatives (from the java-common package). The update-alternatives command will not update every one of the symbolic links for various java /bin executables, which is why update-java-alternatives is better.

    So to go for OpenJDK 6 to 7, use update-java-alternatives -l to get a list of Java alternatives and then used sudo update-java-alternatives -s java-1.7.0-openjdk-amd64 to switch the JDK.

    CAVEAT: The command above might throw the following errors,

    update-alternatives: error: no alternatives for mozilla-javaplugin.so.
    update-java-alternatives: plugin alternative does not exist: 
      /usr/lib/jvm/java-7-openjdk-amd64/jre/lib/amd64/IcedTeaPlugin.so
    

    This is because the openjdk plugin is not installed by default. To fix run sudo apt-get install icedtea-7-plugin and rerun update-java-alternatives.

    0 讨论(0)
  • 2021-02-01 14:37

    If you use Ubuntu you can specify which JVM you want to use via command (works only for JVM installed from apt-get or aptitude)

    sudo update-alternatives --config java

    Or by setting JAVA_HOME. Here is good tutorial:

    http://vietpad.sourceforge.net/javaonlinux.html

    0 讨论(0)
  • 2021-02-01 14:42

    With JVMs, if you need to switch between them you just need to use a batch file (or powershell script) to manage the classpath and JVM path. You don't need to rely on the system default JVM path and instead just allow your app to point to whatever JVM you like by changing classpath and JVM path environment in the shell that runs the JVM.

    For programs that are getting Java location from the Registry, in theory you could use a batch script to update that also.

    In this respect Java is way easier than "Ruby version manager".

    0 讨论(0)
  • 2021-02-01 14:44

    SDKMAN! is a similar tool for the Java ecosystem. Supports various Java versions, Scala, Clojure, Kotlin, Groovy, and build tools like Maven and Gradle.

    Works on Mac and Linux, with some mentions of support for Windows depending on how hard you are willing to try :)

    0 讨论(0)
  • 2021-02-01 14:44

    For the sake of completeness, there are two more - jabba (of which I am the author; written in Go and designed after nvm/gvm/rvm) and jenv (not to confuse with jenv.be; doesn't support installation from oracle but can install from a custom zip).

    0 讨论(0)
  • 2021-02-01 14:47

    http://www.jenv.be/ will allow this type of control.

    0 讨论(0)
提交回复
热议问题