To celebrate the release of GATK 4.0, we are giving away free credits for running the GATK4 Best Practices pipelines in FireCloud, our secure online analysis portal. It’s first come first serve, so sign up now to claim your free credits worth $250. Sponsored by Google Cloud. Learn more at

Need to run programs that require different versions of Java

The problem

We sometimes need to be able to use multiple versions of Java on the same computer to run command-line tools that have different version requirements. For example, at one point, GATK required an older version of Java (1.7), whereas Picard required the most recent version (1.8). Now they're both on the same version of Java (1.8), but what if you need to run something else with a different Java version requirement?

The solution(s)

First, have you considered using Docker containers? We strongly encourage you to look into them...

But if that's not an option for you, here's an alternate solution that is reasonably painless (illustrated using Java 1.7 and 1.8).

You will need to have both versions of Java installed on your machine. The Java installation package for 1.8 can be found here, and the package for 1.7 is here. Note that we point to the “JDK” (Java Development Kit) packages because they are the most complete Java packages (suitable for developing in Java as well as running Java executables), and we have had reports that the “JRE” (Java Runtime Environment) equivalents were not sufficient to run GATK on some machines.

First, check your current default java version by opening your terminal and typing java -version. If the version starts with "1.8", you will need to add the following code to the beginning of your GATK command to specify that it should be run using version 1.7. Note that this is not compatible with the use of the gatk wrapper script.


If your default version starts with “1.7”, then you will need to prepend the code below to your Picard command:


You may need to change the orange part in each code snippet, which should refer to the specific version of java you have installed on your machine (version and update). To find that, simply navigate to the folder where you had installed the JDK. Under the “JavaVirtualMachines” folder, you should find JDK folders that name the specific version and update.

Post edited by Geraldine_VdAuwera on
Sign In or Register to comment.