Forge Home

java

Installs the correct Java package on various platforms.

23,461,675 downloads

3,882 latest version

5.0 quality score

We run a couple of automated
scans to help you access a
module's quality. Each module is
given a score based on how well
the author has formatted their
code and documentation and
modules are also checked for
malware using VirusTotal.

Please note, the information below
is for guidance only and neither of
these methods should be considered
an endorsement by Puppet.

Version information

  • 11.0.1 (latest)
  • 11.0.0
  • 10.1.2
  • 10.1.1
  • 10.1.0
  • 10.0.0
  • 9.0.1
  • 9.0.0
  • 8.2.0
  • 8.1.0
  • 8.0.0
  • 7.3.0
  • 7.2.0
  • 7.1.1
  • 7.1.0
  • 7.0.2
  • 7.0.1
  • 7.0.0
  • 6.5.0
  • 6.4.0
  • 6.3.0
  • 6.2.0
  • 6.1.0
  • 6.0.0
  • 5.0.1
  • 5.0.0
  • 4.1.0
  • 4.0.0
  • 3.3.0
  • 3.2.0
  • 3.1.0
  • 3.0.0
  • 2.4.0
  • 2.3.0
  • 2.2.0
  • 2.1.1
  • 2.1.0
  • 2.0.0
  • 1.6.0
  • 1.5.0
  • 1.4.3
  • 1.4.2
  • 1.4.1
  • 1.4.0
  • 1.3.0
  • 1.2.0
  • 1.1.2
  • 1.1.1
  • 1.1.0
  • 1.0.1
  • 1.0.0
  • 0.3.0
  • 0.2.0
  • 0.1.6
  • 0.1.5
  • 0.1.4
  • 0.1.3
  • 0.1.2
  • 0.1.1
released Oct 7th 2024
This version is compatible with:
  • Puppet Enterprise 2023.8.x, 2023.7.x, 2023.6.x, 2023.5.x, 2023.4.x, 2023.3.x, 2023.2.x, 2023.1.x, 2023.0.x, 2021.7.x, 2021.6.x, 2021.5.x, 2021.4.x, 2021.3.x, 2021.2.x, 2021.1.x, 2021.0.x
  • Puppet >= 7.0.0 < 9.0.0
  • , , , , , , ,

Start using this module

  • r10k or Code Manager
  • Bolt
  • Manual installation
  • Direct download

Add this module to your Puppetfile:

mod 'puppetlabs-java', '11.0.1'
Learn more about managing modules with a Puppetfile

Add this module to your Bolt project:

bolt module add puppetlabs-java
Learn more about using this module with an existing project

Manually install this module globally with Puppet module tool:

puppet module install puppetlabs-java --version 11.0.1

Direct download is not typically how you would use a Puppet module to manage your infrastructure, but you may want to download the module in order to inspect the code.

Download

Documentation

puppetlabs/java — version 11.0.1 Oct 7th 2024

java

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. License
  8. Development - Guide for contributing to the module

Overview

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.

Setup

Beginning with the java module

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

Usage

The java module installs the correct jdk or jre package on a wide variety of systems. By default, the module installs 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',
}

To install the latest patch version of Java 8 on CentOS

class { 'java' :
  package => 'java-1.8.0-openjdk-devel',
}

The defined type java::download installs one or more versions of Java SE from a remote url. java::download depends on puppet/archive.

To install Java to a non-default basedir (defaults: /usr/lib/jvm for Debian; /usr/java for RedHat):

java::download { 'jdk8' :
  ensure  => 'present',
  java_se => 'jdk',
  url     => 'http://myjava.repository/java.tgz",
  basedir => '/custom/java',
}

AdoptOpenJDK

The defined type java::adopt installs one or more versions of AdoptOpenJDK Java. java::adopt depends on puppet/archive.

java::adopt { 'jdk8' :
  ensure  => 'present',
  version => '8',
  java => 'jdk',
}

java::adopt { 'jdk11' :
  ensure  => 'present',
  version => '11',
  java => 'jdk',
}

To install a specific release of a AdoptOpenJDK Java version, e.g. 8u202-b08, provide both parameters version_major and version_minor as follows:

java::adopt { 'jdk8' :
  ensure  => 'present',
  version_major => '8u202',
  version_minor => 'b08',
  java => 'jdk',
}

To install AdoptOpenJDK Java to a non-default basedir (defaults: /usr/lib/jvm for Debian; /usr/java for RedHat):

java::adopt { 'jdk8' :
  ensure  => 'present',
  version_major => '8u202',
  version_minor => 'b08',
  java => 'jdk',
  basedir => '/custom/java',
}

To ensure that a custom basedir is a directory before AdoptOpenJDK Java is installed (note: manage separately for custom ownership or perms):

java::adopt { 'jdk8' :
  ensure  => 'present',
  version_major => '8u202',
  version_minor => 'b08',
  java => 'jdk',
  manage_basedir => true,
  basedir => '/custom/java',
}

Adoptium Temurin

Adoptium Temurin is the successor of AdoptOpenJDK and is supported using the defined type java::adoptium. It depends on puppet/archive.

The java::adoptium defined type expects a major, minor, patch and build version to download the specific release. It doesn't support jre downloads as the other distributions.

java::adoptium { 'jdk16' :
  ensure  => 'present',
  version_major => '16',
  version_minor => '0',
  version_patch => '2',
  version_build => '7',
}
java::adoptium { 'jdk17' :
  ensure  => 'present',
  version_major => '17',
  version_minor => '0',
  version_patch => '1',
  version_build => '12',
}

To install Adoptium to a non-default basedir (defaults: /usr/lib/jvm for Debian; /usr/java for RedHat):

java::adoptium { 'jdk7' :
  ensure  => 'present',
  version_major => '17',
  version_minor => '0',
  version_patch => '1',
  version_build => '12',
  basedir => '/custom/java',
}

To ensure that a custom basedir is a directory before Adoptium is installed (note: manage separately for custom ownership or perms):

java::adoptium { 'jdk8' :
  ensure  => 'present',
  version_major => '17',
  version_minor => '0',
  version_patch => '1',
  version_build => '12',
  manage_basedir => true,
  basedir => '/custom/java',
}

SAP Java (sapjvm / sapmachine)

SAP also offers JVM distributions. They are mostly required for their SAP products. In earlier versions it is called "sapjvm", in newer versions they call it "sapmachine".

The defined type java::sap installs one or more versions of sapjvm (if version 7 or 8) or sapmachine (if version > 8) Java. java::sap depends on puppet/archive. By using this defined type with versions 7 or 8 you agree with the EULA presented at https://tools.hana.ondemand.com/developer-license-3_1.txt!

java::sap { 'sapjvm8' :
  ensure  => 'present',
  version => '8',
  java => 'jdk',
}

java::sap { 'sapmachine11' :
  ensure  => 'present',
  version => '11',
  java => 'jdk',
}

To install a specific release of a SAP Java version, e.g. sapjvm 8.1.063, provide parameter version_full:

java::sap { 'jdk8' :
  ensure  => 'present',
  version_full => '8.1.063',
  java => 'jdk',
}

To install SAP Java to a non-default basedir (defaults: /usr/lib/jvm for Debian; /usr/java for RedHat):

java::adopt { 'sapjvm8' :
  ensure  => 'present',
  version_full => '8.1.063',
  java => 'jdk',
  basedir => '/custom/java',
}

To ensure that a custom basedir is a directory before SAP Java is installed (note: manage separately for custom ownership or perms):

java::adopt { 'sapjvm8' :
  ensure  => 'present',
  version_full => '8.1.063',
  java => 'jdk',
  manage_basedir => true,
  basedir => '/custom/java',
}

Reference

For information on the classes and types, see the REFERENCE.md. For information on the facts, see below.

Facts

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.
  • java_default_home: The absolute path to the java system home directory (only available on Linux). For instance, the java executable's path would be ${::java_default_home}/jre/bin/java. This is slightly different from the "standard" JAVA_HOME environment variable.
  • java_libjvm_path: The absolute path to the directory containing the shared library libjvm.so (only available on Linux). Useful for setting LD_LIBRARY_PATH or configuring the dynamic linker.

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

Limitations

For an extensive list of supported operating systems, see metadata.json

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 can 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) 7, 8, 9
  • CentOS 7, 8
  • Oracle Linux 7
  • Debian 10, 11
  • Ubuntu 18.04, 20.04, 22.04
  • Solaris 11
  • SLES 12, 15

Oracle Java is supported on:

  • CentOS 7
  • CentOS 8
  • Red Hat Enterprise Linux (RHEL) 7

AdoptOpenJDK Java is supported on:

  • CentOS
  • Red Hat Enterprise Linux (RHEL)
  • Amazon Linux
  • Debian

Adoptium Temurin Java is supported on:

  • CentOS
  • Red Hat Enterprise Linux (RHEL)
  • Amazon Linux
  • Debian

SAP Java 7 and 8 (=sapjvm) are supported (by SAP) on:

  • SLES 12, 15
  • Oracle Linux 7, 8
  • Red Hat Enterprise Linux (RHEL) 7, 8

(however installations on other distributions mostly also work well)

For SAP Java > 8 (=sapmachine) please refer to the OpenJDK list as it is based on OpenJDK and has no special requirements.

Known issues

Where Oracle change the format of the URLs to different installer packages, the curl to fetch the package may fail with a HTTP/404 error. In this case, passing a full known good URL using the url parameter will allow the module to still be able to install specific versions of the JRE/JDK. Note the version_major and version_minor parameters must be passed and must match the version downloaded using the known URL in the url parameter.

OpenBSD

OpenBSD packages install Java JRE/JDK in a unique directory structure, not linking the binaries to a standard directory. Because of that, the path to this location is hardcoded in the java_version fact. Whenever you upgrade Java to a newer version, you have to update the path in this fact.

License

This codebase is licensed under the Apache2.0 licensing, however due to the nature of the codebase the open source dependencies may also use a combination of AGPL, BSD-2, BSD-3, GPL2.0, LGPL, MIT and MPL Licensing.

Development

Puppet modules on the Puppet Forge are open projects, and community contributions are essential for keeping them great. To contribute to Puppet projects, see our module contribution guide.

Contributors

The list of contributors can be found at https://github.com/puppetlabs/puppetlabs-java/graphs/contributors.