VOOZH about

URL: https://www.javacodegeeks.com/2019/12/managing-multiple-java-installations.html

⇱ Managing multiple Java installations - Java Code Geeks


With more and more Java releases coming up, it’ll be more interesting to manage multiple Java installations on your local environment. Different projects may require different Java versions.

The jenv project is a convenient way how to manage Java installations. It can setup local Java installations on global, directory and shell level and uses easy-to-remember Java version identifiers:

$> jenv versions
 11
 12.0
 13.0
 1.8
* 1.8.0.152
 9.0
 9.0.4
 openj9-jdk-12.0.1
 openj9-jdk-13.0.1
 openjdk64-11.0.2
 openjdk64-12.0.1
 openjdk64-13.0.1
 oracle64-1.8.0.152
 oracle64-9.0.4

# switch to JDK 13 globally
$> jenv global 13.0

# switch to JDK 9 locally
$> cd project/
$> jenv local 9.0

$> java -version
java version "9.0.4"
Java(TM) SE Runtime Environment (build 9.0.4+11)
Java HotSpot(TM) 64-Bit Server VM (build 9.0.4+11, mixed mode)

$> cd .. && java -version
openjdk version "13.0.1" 2019-10-15
OpenJDK Runtime Environment AdoptOpenJDK (build 13.0.1+9)
Eclipse OpenJ9 VM AdoptOpenJDK (build openj9-0.17.0, ...)

Jenv stores the local Java version in a .java-version file.

Jenvs works by declaring wrapper java binaries that direct to the corresponding installation based on the context.

Shell scripts can also set a specific version via the JENV_VERSION environment variable:

#!/bin/bash

JENV_VERSION='13.0'

# will use JDK 13
java -version

Some of the content of this post was reposted from my newsletter issue 025.

Published on Java Code Geeks with permission by Sebastian Daschner, partner at our JCG program. See the original article here: Code Ready Containers – Getting Started with HR Employee Rewards Project in the Cloud

Opinions expressed by Java Code Geeks contributors are their own.

Do you want to know how to develop your skillset to become a Java Rockstar?
Subscribe to our newsletter to start Rocking right now!
To get you started we give you our best selling eBooks for FREE!
1. JPA Mini Book
2. JVM Troubleshooting Guide
3. JUnit Tutorial for Unit Testing
4. Java Annotations Tutorial
5. Java Interview Questions
6. Spring Interview Questions
7. Android UI Design
and many more ....
I agree to the Terms and Privacy Policy

Thank you!

We will contact you soon.

πŸ‘ Photo of Sebastian Daschner
Sebastian Daschner
December 5th, 2019Last Updated: December 3rd, 2019
1 253 1 minute read

Sebastian Daschner

Sebastian Daschner is a self-employed Java consultant and trainer. He is the author of the book 'Architecting Modern Java EE Applications'. Sebastian is a Java Champion, Oracle Developer Champion and JavaOne Rockstar.
Subscribe

This site uses Akismet to reduce spam. Learn how your comment data is processed.

1 Comment
Oldest
Newest Most Voted
6 years ago

Hi…
I’m Elena gillbert.jEnv is a command line tool to help you forget how to set the JAVA_HOME environment variable. So, while it doesn’t install different versions of Java, jEnv makes it much easier to manage the versions already on your machine (like those installed by jabba). Just a note that, unfortunately for Windows users, it is not currently cross-platform.

0
Reply
Back to top button
Close
wpDiscuz