Problem: Working with several Java versions
On my first day at jambit, I picked up my laptop and installed JDK 1.8. After that, I was able to develop cool Java applications for our customers for several years without any great changes. But ever since September 2017, a new Java version has been released every 6 months.
This means that I often work on code bases compiled with different Java versions at the same time. Sometimes there are two separate projects. But it is also quite possible that there are two microservices in the same project.
The simple switching between different Java versions is therefore essential.
The solution: Quick switching with jEnv
Among many options, jEnv offers the possibility to switch between different Java versions quickly and easily.
After the successful installation, you first add all Java versions available on your computer to jEnv-Configs.
Afterwards, you can set the global version in jEnv or list the existing versions at any time.
$ jenv global oracle64-13.0.2 $ jenv versions system oracle64-22.214.171.124 * oracle64-13.0.2 (set by /Users/jambitUser/.jenv/version)
You can always see the current Java version with jenv version and the path of executables with jenv which java.
A useful feature of jEnv is that you can set different Java versions on the directory level.
../foo:~$ jenv local oracle64-13.0.2
../bar:~$ jenv local oracle64-126.96.36.199
The directory /foo uses Java 13 and the directory /bar uses Java 8. The version for a shell session is set a similar way.
- There are other similar tools such as SDKMAN and Jabba.
- jEnv is currently only available for Mac and Linux. The issue for Windows support is currently open on GitHub.
Author: Dvin Galstian / Senior Software Architect / Business Division New Business