How can I change JDK 1.8 to JDK 11 in Heroku?

Viewed 1416

I created pipelines for bitbucket to deploy app to Heroku. I use java 11 but Heroku installs 1.8. enter image description here

How to fix it?

I also created system.properties in main/resources indicating JDK and Maven versions:

enter image description here

3 Answers

Create a system.properties file in your directory and commit to git. more info https://devcenter.heroku.com/articles/customizing-the-jdk#prerequisites see doc for more info.

Firstly, check what the system.properties file definitely got into your Git-repository by using git ls-files.

Secondly, check what the first 3 bytes of the file are not UTF-8 BOM.

README

If you don't want to add a additional file (system.properties) in your code like me, then this answer would help.


Idea: Change java buildpack jdk default version from 1.8 to 11

Step:

  1. Fork official java buildpack: https://github.com/heroku/heroku-buildpack-java. e.g. https://github.com/archongum/heroku-buildpack-java
  2. Find out where the default jdk version variable is.

enter image description here

  1. Commit changes and Push to GitHub
  2. Add your own buildpack in Heroku enter image description here
  3. Trigger deploy and done enter image description here
Related