How to add Oracle JRE to TPCF commercial Java Buildpack
search cancel

How to add Oracle JRE to TPCF commercial Java Buildpack

book

Article ID: 406683

calendar_today

Updated On:

Products

VMware Tanzu Platform - Cloud Foundry VMware Tanzu Application Service

Issue/Introduction

The Cloud Foundry (CF) buildpacks and the Tanzu Platform for Cloud Foundry buildpacks have diverged. 

This article describes how to add and enable Oracle JRE in a Tanzu Platform for Cloud Foundry commercial Java Buildpack.

Environment

Tanzu Platform for Cloud Foundry

Resolution

Starting with Java Buildpack version 4.84.0, customer can follow the below steps to add Oracle JRE to the commercial Java Buildpack:

Part 1: Hosting a repository with Oracle JRE dependency

1. Start by downloading Oracle JRE from Oracle website. Please ensure you have a valid license for production use.

2. Create a directory and put JRE package into the directory:

mkdir oracle_cache
mv jre-8u202-linux-x64.tar.gz oracle_cache
cd oracle_cache

3. Create a file index.yml with syntax like below.

vim index.yml 
---
1.8.0_202: http://oracle_cache.apps.example.com/jre-8u202-linux-x64.tar.gz

Replace 1.8.0_202 with JRE version that you downloaded from Oracle.
Replace <apps.example.com> with app domain that repository will be hosted on.
Replace jre-8u202-linux-x64.tar.gz with the package name of Oracle JRE (file downloaded earlier).

4. Create a file manifest.yml with syntax like below:

vim manifest.yml 
---
applications:
- name: oracle_cache
  memory: 64M
  path: .
  buildpack: staticfile_buildpack

5. Push the application to any temporary space on Cloud Foundry:

cf push oracle_cache
Pushing app oracle_cache to org test / space test as admin...
...
routes:            oracle_cache.apps.example.com
...
#0   running   2025-08-12T11:06:37Z   0.0%   0B of 64M   0B of 1G   0B/s of 0B/s

You now have a repository running which hosts your licensed Oracle JRE version!


Part 2: Customizing and building Java Buildpack with Oracle JRE

1. Download 'Java buildpack' online from Broadcom Portal and unzip the online buildpack zip file.

unzip java-buildpack-v4.84.0.zip -d java-buildpack/
cd java-buildpack

2. Edit the components.yml and disable OpenJdk and enable OracleJRE:

vim config/components.yml
#  - "JavaBuildpack::Jre::OpenJdkJRE"
    - "JavaBuildpack::Jre::OracleJRE"

3. Edit the oracle_jre.yml version, version_lines and repository_root to match repository generated in part 1.

vim config/oracle_jre.yml
jre:
version: 1.8.0_+
  version_lines:
  - 1.8.0_+
repository_root: http://oracle_cache.apps.example.com/

Replace 1.8.0_+ with the major version of the Oracle JRE obtained in Part 1, leaving the version value open for dynamic assignment. Additionally, replace repository root with URL of oracle_cache static_file repository app created in part 1.

4. Run the bundle install commands to generate a customized buildpack.

bundle install

bundle exec rake clean package OFFLINE=true PINNED=true
...
Creating build/java-buildpack-offline-v4.84.0.zip

You now have a customized java buildpack installed with Oracle JRE!

 

Part 3: Testing and using customized Java buildpack with Oracle JRE

1. Upload the Java buildpack from the previous step to Cloud Foundry:

cf create-buildpack java_test build/java-buildpack-offline-v4.84.0.zip 10

Be careful with priority (10 above) as java applications by default will use highest priority java buildpack in the environment.

2. Download a sample Java app to use with new Java buildpack and push that application: 

cf push spring-music -b java_test

3. CF SSH to the newly pushed java app:

cf ssh spring-music

4. Confirm that the Runtime Environment version matches the version downloaded from Oracle:

cd /home/vcap/app/.java-buildpack/oracle_jre/bin

./java -version
java version "1.8.0_202"
Java(TM) SE Runtime Environment (build 1.8.0_202-b08)
Java HotSpot(TM) 64-Bit Server VM (build 25.202-b08, mixed mode)

You have now validated that commercial Java buildpack is working with customized Oracle JRE!