You have to create a file called system.properties in the root of your project, and therein have the following entry:
java.runtime.version=12
However, Heroku does not support runtime version 10, 12, only the odd numbers (so 11, 13, 15 as of this article). See https://devcenter.heroku.com/articles/java-support#supported-java-versions
Be sure to have both pom.xml and system.properties are targeting the same version.