Java Buildpacks: all versions
This KB article describes how to add and enable Oracle JRE in a customized Java Buildpack.
The Oracle JRE provides Java runtimes from Oracle project. No versions of the JRE are available by default due to licensing restrictions. Therefore it is necessary to manually add Oracle JRE package into a custom built Java Buildpack.
You will need to create a repository with Oracle JRE in it and configure the buildpack to use that repository. Unless otherwise configured, the version of Java that will be used is specified in
This is long-form procedure of steps outlined in: https://github.com/cloudfoundry/java-buildpack/blob/master/docs/jre-oracle_jre.md
Part 1: Hosting a repository with Oracle JRE dependency:
1. Start by downloading Oracle JRE from Oracle website.
2. Create a directory and put JRE package into the directory:
mv jre-8u151-linux-x64.tar.gz oracle_cache
3. Create a file index.yml with syntax like below.
Replace 1.8.0_151 with JRE version that you downloaded from oracle.
Replace <apps.example.com> with app domain that repository will be hosted on.
Replace jre-8u151-linux-x64.tar.gz with package name of Oracle JRE (file downloaded earlier).
4. Create a file manifest.yml with syntax like below:
- name: oracle_cache
5. Push the application to any temporary space on Cloud Foundry:
cf push oracle_cache
Showing health and status for app oracle_cache in org test / space test as admin...
#0 running 2017-11-14 10:35:13 AM 0.0% 4.7M of 64M 82.1M of 1G
You now have a repository running which hosts your licensed Oracle JRE version!
Part 2: Customizing and building Java Buildpack with Oracle JRE
1. Clone the Java buildpack:
git clone https://github.com/cloudfoundry/java-buildpack.git
2. Check out the desired version of java buildpack that you want to use:
git checkout <your desired version> eg:- git checkout v4.6
3. Edit the components.yml and disable OpenJdk and enable OracleJRE by changing commenting:
# - "JavaBuildpack::Jre::OpenJdkJRE"
4. Edit the oracle_jre.yml version and repository_root to match repository generated in part 1.
Replace 1.8.0_151 with version of Oracle JRE downloaded in part 1.
Replace repository root with URL of oracle_cache static_file repository app created in part 1.
5. Run the bundle install commands to generate a customized buildpack.
bundle exec rake clean package OFFLINE=true PINNED=true
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 previous step to Cloud Foundry:
cf create-buildpack java_test build/java-buildpack-offline-v4.6.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 version downloaded from Oracle:
java version "1.8.0_151"
Java(TM) SE Runtime Environment (build 1.8.0_151-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.151-b12, mixed mode)
You have now validated that Java buildpack is working with customized Oracle JRE!