Last Updated on 29 October 2021   |   Print Email
By default, Java apps deployed on Heroku will be running under JDK 1.8, as you can see when deploying an app via Heroku CLI:To change this default Java version, you have to create the system.propertiesfile under the project’s root directory, with the following content:
java.runtime.version=<jdk_version>
For example, to use JDK 15:
java.runtime.version=15
As of October 2021, Heroku supports Java versions 1.7, 1.8, 11, 13, 15, 16 and 17.Then, if you deploy via Git push using Heroku CLI, you need to run the following commands to redeploy the app:
git add .
git commit –m “use java version 15”
git push heroku master
Then you should see it is installing JDK 15 for compiling and building the app:Now your app is running under the JDK version you specified.
Nam Ha Minh is certified Java programmer (SCJP and SCWCD). He started programming with Java in the time of Java 1.4 and has been falling in love with Java since then. Make friend with him on Facebook and watch his Java videos you YouTube.