Nov 1, 2018

Automatically Install JDK in Jenkins

You can ask Jenkins to install Java for you. In this case, Jenkins will download the JDK installation and install a copy on your machine. The first time a build needs to use this JDK, Jenkins will download and install the specified version of Java into the tools directory in the Jenkins home directory. The default JDK location is something like:


If the build is running on a new build agent that doesn’t have this JDK installed, it will download and install it onto the build agent machine as well.

This is also a great way to configure build agents. Jenkins can delegate build jobs to other machines, or build agents. A build agent (or “slave”) is simply another computer that Jenkins can use to run some of its builds. If you use Jenkins’s Install automatically option, you don’t need to manually install all the JDK versions you need on the build agent machines—Jenkins will do it for you the first time it needs to.