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 Cromwell requires the most recent version (1.8). So in order to run WDL scripts that include GATK tasks on the Cromwell execution engine, we need to have a way to specify which version of Java we want to use without having to install and uninstall versions each time. Here 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 JDK for 1.8 can be found here, and the JDK 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 each of the calls to a GATK tool to specify that it should be run using version 1.7. Since you are running this command from within a WDL script using Cromwell, this means adding the below code (adapted for the specific “update” version you have on your machine) in front of each call to GATK within the “command” section of the WDL script. For more information on WDL script components, please see our user guide.
If your default version starts with “1.7”, then you will need to prepend the code below to your calls to Cromwell, instead of adding the above code to your GATK calls.
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.