Search code examples
javamavenspring-bootcloud-foundry

Specify JDK's version in pom.xml or manifest.yml?


I have an java application which I would like to deploy it to cloud foundry. And I want to specify the JDK version of it. I searched some articles but I'm confused where to do it.

In some articles it says that I need to use java-buildpack and specify the environment in manifest.yml or in cf command. e.g. How can I change the version of Java used in Bluemix?

But some others say that I could specify the JDK version in pom.xml with -source and -target properties. e.g. http://maven.apache.org/plugins/maven-compiler-plugin/examples/set-compiler-source-and-target.html

Can anyone tell me the difference and which one should I choose?


Solution

  • You need to supply the JRE version with your application manifest.yml file.

    The java buildpack currently supports OpenJDK, Oracle or Azul Zulu JREs. Assuming you are using OpenJDK, JRE versions 1.6, 1.7 and 1.8 are supported out-of-the-box by the buildpack.

    To set the JRE version just specify an environment variable in your application manifest as follows:

    ---
    applications:
    - name: my-java-app
      memory: 512M
      env:
        JBP_CONFIG_OPEN_JDK_JRE: '{ jre: { version: 1.8.0_+ } }'
    

    The java buildpack does not look at the pom.xml file. It assumes you deploy a compiled version of your app (e.g. a JAR or WAR file.)