Mastodon

Cloudfoundry with OpenJDK 11 - Add JBP_CONFIG_OPEN_JDK_JRE

I just upgraded a Java project from Java 8 to OpenJDK 11. The project is running on a Cloudfoundry, using the Java buildpack. After successful deployment with the new Java 11, the application won’t start properly and threw the a java.lang.UnsupportedClassVersionError. The solution for this is to add the following variable in Cloudfoundry:

"JBP_CONFIG_OPEN_JDK_JRE" with value "{ jre: { version: 11.+ }}"

This can also be done via manifest file:

---
applications:
  - name: myapp
    instances: 1
    path: ./target/myapp-0.0.1-SNAPSHOT.jar
    buildpacks:
      - java_buildpack_cached
    env:
      JBP_CONFIG_OPEN_JDK_JRE: '{ "jre": { version: 11.+ } }'

This tells the Java buildpack to explicitely use Java 11 instead of the default Java 8. Thanks to my coworker Stefan for pointing this out. :)