How can I change the version of Java used in Bluem

2019-07-02 17:32发布

问题:

I have an old legacy Java app that I am trying to run in Bluemix. I would like to use either Java 1.5 or Java 1.6. How would I do this?

回答1:

You need to use the Java buildpack, the Java buildpack is available at https://github.com/cloudfoundry/java-buildpack.

To use it when you deploy your app you can either add it to manifest.yml or use the Cloud Foundry CLI to specify the buildpack. You can do that with the following.

cf push myappname -b https://github.com/cloudfoundry/java-buildpack.git

manifest.yml

applications:
- path: .
  memory: 512MB
  instances: 1
  domain: mybluemix.net
  name: myappname
  host: myappname
  disk_quota: 1024M
  buildpack: https://github.com/cloudfoundry/java-buildpack.git

Once you deploy your app with that buildpack you can specify the version of Java with the following command.

cf set-env myappname JBP_CONFIG_OPEN_JDK_JRE '{jre: { version: 1.7.0_+ }}'

You can then change the version of Java for your app by changing 1.7.0 to whatever version you want.

You will need to restart/restage your app after you change the Java version though. You can do this with the following.

cf restage myappname