Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Puppet Module to manage Java
Ruby Puppet



Table of Contents

  1. Overview
  2. Module Description - What the module does and why it is useful
  3. Setup - The basics of getting started with the java module
  4. Usage - Configuration options and additional functionality
  5. Reference - An under-the-hood peek at what the module is doing and how
  6. Limitations - OS compatibility, etc.
  7. Development - Guide for contributing to the module


Installs the correct Java package on various platforms.

Module Description

The java module can automatically install Java jdk or jre on a wide variety of systems. Java is a base component for many software platforms, but Java system packages don't always follow packaging conventions. The java module simplifies the Java installation process.


Beginning with the java module

To install the correct Java package on your system, include the java class: include java.


The java module installs the correct jdk or jre package on a wide variety of systems. By default, the module will install the jdk package, but you can set different installation parameters as needed. For example, to install jre instead of jdk, you would set the distribution parameter:

class { 'java':
  distribution => 'jre',



Public classes

  • java: Installs and manages the Java package.

Private classes

  • java::config: Configures the Java alternatives.

  • java::params: Builds a hash of jdk/jre packages for all compatible operating systems.


The following parameters are available in java:


Specifies the Java distribution to install.
Valid options: 'jdk', 'jre', or, where the platform supports alternative packages, 'sun-jdk', 'sun-jre', 'oracle-jdk', 'oracle-jre'. Default: 'jdk'.


Specifies the name of the Java alternative to use. If you set this parameter, you must also set the java_alternative_path.
Valid options: Run command update-java-alternatives -l for a list of available choices. Default: OS and distribution dependent defaults on *deb systems, undef on others.


Required when java_alternative is specified. Defines the path to the java command.
Valid option: String. Default: OS and distribution dependent defaults on *deb systems, undef on others.


Specifies the name of the Java package. This is configurable in case you want to install a non-standard Java package. If not set, the module will install the appropriate package for the distribution parameter and target platform. If you set package, the distribution parameter will do nothing.
Valid option: String. Default: undef.


Sets the version of Java to install, if you want to ensure a particular version.
Valid options: 'present', 'installed', 'latest', or a string matching /^[.+_0-9a-zA-Z:-]+$/. Default: 'present'.


The java module includes a few facts to describe the version of Java installed on the system:

  • java_major_version: The major version of Java.
  • java_patch_level: The patch level of Java.
  • java_version: The full Java version string.

Note: The facts return nil if Java is not installed on the system.


This module cannot guarantee installation of Java versions that are not available on platform repositories.

This module only manages a singular installation of Java, meaning it is not possible to manage e.g. OpenJDK 7, Oracle Java 7 and Oracle Java 8 in parallel on the same system.

Oracle Java packages are not included in Debian 7 and Ubuntu 12.04/14.04 repositories. To install Java on those systems, you'll need to package Oracle JDK/JRE, and then the module will be able to install the package. For more information on how to package Oracle JDK/JRE, see the Debian wiki.

This module is officially supported for the following Java versions and platforms:

OpenJDK is supported on:

  • Red Hat Enterprise Linux (RHEL) 5, 6, 7
  • CentOS 5, 6, 7
  • Oracle Linux 6, 7
  • Scientific Linux 5, 6
  • Debian 6, 7
  • Ubuntu 10.04, 12.04, 14.04
  • Solaris 11
  • SLES 11 SP1, 12

Sun Java is supported on:

  • Debian 6


Puppet Labs modules on the Puppet Forge are open projects, and community contributions are essential for keeping them great. We can’t access the huge number of platforms and myriad hardware, software, and deployment configurations that Puppet is intended to serve. We want to keep it as easy as possible to contribute changes so that our modules work in your environment. There are a few guidelines that we need contributors to follow so that we can have a chance of keeping on top of things. For more information, see our module contribution guide.


The list of contributors can be found at:

Something went wrong with that request. Please try again.