

# a utility script to set java environment variables The Path variable, if not set based on the JVM_HOME variable (i.e., %JAVA_HOME%/bin) and was set manually, will contain the.The Java versions are installed on the default location, which is %USERPROFILE%\.jabba\jdk.All the Java versions are setup using Jabba.If the Path environment variable already contains a JDK entry, it should update the same instead of adding a new entry, which might corrupt the setup.īefore we look at the batch-script itself, I want to highlight the following assumptions:.It should not update the System environment variables.Update the JAVA_HOME and Path environment variables for the current user.I drafted a list of requirements that the script should support. But when you have more than a few versions installed, manually updating the environment variables to point to the required version quickly becomes a challenge.


If we need to persist the value of these, we need to manually put these in the environment variables. Jabba install problem with Jabba is that the Path and JAVA_HOME variables set via the use command last only the current session. Jabba install fetch and install adoptOpenJdk versions available in the remote repo In its simplest version, the following commands will install openjdk15 and adoptOpenJdk8 on the machine: # fetch and install openjdk versions available in the remote repo You can look into the official documentation for the support. Once Jabba is installed, we can use the same to install different Java versions as per the requirement. All you need to do is run the following command from PowerShell as an administrator. In the following sections, we will see how we can use Jabba (for installation of various versions) and a custom batch script to switch between these (Jabba installed) versions to solve the issues mentioned earlier. jEnv, on the other hand, does not work at all on Windows PC machine and can only be used for Mac or Linux based setups. Jabba can install multiple Java versions on a Windows PC machine, but it does not set the corresponding persistent JAVA_HOME or Path variables for the current user. It is relatively easy to switch between different versions on a Mac or Linux-based system, thanks to utilities like Jabba and jEnv But on Windows, this is not as straightforward. When Oracle decided to go with the six-month release cycle for new Java versions, many developers started to work with more than one Java version at a time.
