Pivotal Knowledge Base


How do I use an Oracle JVM on PWS?


Pivotal Web Services (PWS): All versions 


By default, the Java buildpack will deploy your application using the latest OpenJDK release.  In many cases, this is OK as it functions very similar to JVMs produced by other vendors, like Oracle & IBM. The buildpack also supports using the Oracle JVM, but because of licensing restrictions cannot include it out-of-the-box.  This article walks through the steps of using the Oracle JVM on PWS.


The first step to using the Oracle JVM on PWS is to download it.  We recommend downloading the Java 7 or Java 8 Server JRE, but you can also use a full JDK if you need access to functionality not bundled in the JRE.  Regardless, make sure that you download the tar gzipped 64-bit Linux version.  Do not download the RPM version.

The next step is to host your JVM on a public HTTP server.  We recommend an S3 bucket or server running in the AWS US-East-1 data center, as this is where PWS runs and it will make the download very fast.  After you have uploaded the file, note the full URL to access it.

With the URL to the JVM, you need to create an index.yml file.  You can do this with any text editor, the contents should look like this.

1.8.0_45: https://s3.amazonaws.com/<bucket>/path/to/jvm.tar.gz

Be sure to use the correct version number for the JVM that you download and to use the full URL to that download.

With the index.yml file complete, you want to upload that to your HTTP server as well.  The exact path does not matter, but it needs to be public.  Once uploaded, make a note of the URL to it.

The next step is to configure the buildpack to use the Oracle JVM.  To do that, we need to set two environment variables.  Since version 3.0 of the Java buildpack, the buildpack will look at these environment variables and allow you to override its default settings (previous versions required you to fork the Java buildpack).

We recommend setting the environment variables in your manifest.yml file, although you could use cf set-env if you prefer.  Here's an example manifest.yml file, the two environment variables that need to be added are at the bottom.

- name: spring-music
  memory: 512M
  instances: 1
  host: spring-music-${random-word}
  path: build/libs/spring-music.war
    JBP_CONFIG_ORACLE_JRE: '[jre: {repository_root: "https://s3.amazonaws.com/<bucket>/path/to/index/"}]'
    JBP_CONFIG_COMPONENTS: '[jres: ["JavaBuildpack::Jre::OracleJRE"]]'

Note that the URL we configure in this manifest should point to the directory where you put the index.yml file.  It should not have index.yml on the end.

With that done, we can now push the application to PWS.  As this happens, you'll see cf create these two environment variables.  You'll also see in the output from the buildpack that it has downloaded and installed the Oracle JVM that you made available.  If you have any doubts, you can also run cf files <app> app/.java-buildpack which will list the directory where the JVM is installed, which should show you oracle_jre.


The Java buildpack only tracks updates to OpenJDK.  As Oracle publishes a new version of it's JRE, you'll need to make them available to your application.  To do this, you can follow the steps below.

  1. Download the latest version from Oracle.  Again, we recommend the Server JRE and you need the Linux 64-bit tar gzipped version.
  2. Upload it to your HTTP Server or S3 bucket.  Note the URL.
  3. Update the index.yml file, simply add a new line at the bottom with the new version and the URL to it.
  4. Upload the new index.yml file to your HTTPS Server or S3 bucket.
  5. Restage your application with cf restage <app>.  When this runs, the buildpack will automatically grab the latest version from the index.

Failure to do this can result in your application old versions of the JVM, possibly with vulnerabilities.


Powered by Zendesk