created by KateN
on 2016-01-21
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. At the time of writing, GATK requires an older version of Java (1.7), whereas Picard requires the most recent version (1.8). So in order to run both Picard tools and GATK tools on your computer, we present a solution for doing so that is reasonably painless.
You will need to have both versions of Java installed on your machine. The Java installation package for 1.8 can be found [here](http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html), and the package for 1.7 is [here](http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html). 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.
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.
Updated on 2016-04-01
From shlee on 2016-03-25
@KateN Can you point me to the exact link I should click on for the Java 7 download? There is so much information on the Oracle page this doc links to. I want to make sure I have the last updated version of this instead of 1.7.0_75. Thanks.
From shlee on 2016-03-25
I found another site that is easier. It’s [Oracle’s archive](http://www.oracle.com/technetwork/java/javase/downloads/java-archive-downloads-javase7-521261.html) and it gives the link “[Java SE Development Kit 7u80](http://www.oracle.com/technetwork/java/javase/downloads/java-archive-downloads-javase7-521261.html#jdk-7u80-oth-JPR)” for various system versions. I had to create an account with Oracle to download and install.
From KateN on 2016-03-29
I would recommend using the links within the second paragraph of the above article; they will take you to the downloads page on Oracle’s website, where you can download the latest version according to your operating system. There should be no need for you to create an account to download and install.
As a note, select your download from one of the sections titled: “Java SE Development Kit 7u79” or “Java SE Development Kit 7u80”. The page describes the differences between the updates, if you would like to read more about them. I use 7u79 on my machine.
From Xerus on 2017-12-31
How does the command change when I’m on Windows?
From shlee on 2018-01-02
Hi @Xerus,
GATK runs on Unix or Linux. Perhaps you’d be interested in the GATK Docker. Instructions are at https://gatkforums.broadinstitute.org/gatk/discussion/10870/howto-run-gatk4-in-a-docker-container.