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 :)
Answer from jocull on Stack OverflowSDKMAN! 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 :)
http://www.jenv.be/ will allow this type of control.
Java Version Manager inspired by nvm
The reason we never had this for Java is because the JRE always backward compatible and you can tell the compiler to build with compatibility for any previous version.
More on reddit.comGetting started with SDKMAN! – Manage Java, Maven, Gradle versions with ease
Videos
I put together a beginner-friendly guide on SDKMAN!, a super handy tool for managing parallel versions of Java SDKs, Maven, Gradle, and many other development tools right from your terminal.
If you've ever struggled with switching between Java versions for different projects, SDKMAN! can really simplify your workflow.
In the post, I cover:
What SDKMAN! is and why it’s useful.
How to install it.
How to install and switch between SDKs.
Tips for setting a default version.
Hope it helps someone!
Apt-get won't overwrite the existing java versions.
To switch between installed java versions, use the update-java-alternatives command.
List all java versions:
update-java-alternatives --list
Set java version as default (needs root permissions):
sudo update-java-alternatives --set /path/to/java/version
...where /path/to/java/version is one of those listed by the previous command (e.g. /usr/lib/jvm/java-7-openjdk-amd64).
Additional information:
update-java-alternatives is a convenience tool that uses Debian's alternatives system (update-alternatives) to set a bunch of links to the specified java version (e.g. java, javac, ...).
Use
sudo update-alternatives --config java
which lists all installed versions with current active one marked and provides dialog to switch:
There are 3 choices for the alternative java (providing /usr/bin/java).
Selection Path...
------------------------------------------------------------
0 /usr/lib/jvm/java-9-oracle/bin/java...
* 1 /usr/lib/jvm/java-7-oracle/jre/bin/java...
2 /usr/lib/jvm/java-8-oracle/jre/bin/java...
3 /usr/lib/jvm/java-9-oracle/bin/java...
Press <enter> to keep...[*], or type selection number:
Use
export JAVA_HOME="$(jrunscript -e 'java.lang.System.out.println(java.lang.System.getProperty("java.home"));')"
to set $JAVA_HOME from current active version