SysPlay's Blogs

Tag Archives: Java

With ever growing use of Java in multi-platform applications, it is a common problem that different applications need different versions of Java. That means, we need to have multiple versions of Java installed on a system, and keep on switching between them.

But how? By adjusting the JAVA_HOME variable!!! This overall cumbersome looking task has been made quite trivial by using the Java environment manager (jenv) from Gildas Cuisinier. Overall installation & usage instructions on various platforms are given on its home page, as well as on its github repo. However, here’s a quick summary for Linux bash environment:

Add the jenv script in the execution path, basically add the following line in ~/.bash_profie or ~/.profile:

export PATH=${PATH}:~/.jenv/bin

Then, add jenv’s initialization, i.e. add the following line in ~/.bashrc:

eval "$(jenv init -)"

Now, logout and login back for all the settings to take effect. And after logging in, if the system has a pre-installed Java version,

$ jenv versions

should show one line with “* system (set by …”. For other Java version(s), we need to download and add.

In case, corresponding Java version is already downloaded & extracted, go to the next bullet. Otherwise, download the sources (.tar.gz or .bin) of various Java versions you need. Untar the .tar.gz or execute the .bin (after adding execute permissions to it). It would extract them in their corresponding folders. Shown below is one example of each.

Java Downloads

NB There are two variants of Java. One maintained by Oracle (called JDK, Java SE, …) and the other by open source community (called OpenJDK). Here are the corresponding links: