Search code examples
javaherokuheroku-cli

Why isn't Heroku recognising the correct Java version when I've told it explicitly?


Upon git push heroku master on my spring-maven-java project the Heroku cli recognises it is a Java project and attempts to build it. It prints that it is installing JDK 1.8 and after much terminal output it says [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.0:compile (default-compile) on project myProject: Fatal error compiling: invalid target release: 10.0.2

The maven-compiler-plugin configuration source and target explicitly identifies Java 10.0.2 as specified as acceptable by Heroku documentation, and java.runtime.version=10.0.2 is in both application.properties and system.properties

I presume I need to get Heroku to install the correct JDK at the start. How do I get Heroku to get and use Java 10?

See aso the extent to which I've tried modifying maven-compiler-plugin:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>3.8.0</version>
    <configuration>
        <source>10.0.2</source>
        <target>10.0.2</target>
        <release>10.0.2</release>
    </configuration>
    <dependencies>
        <dependency>
            <groupId>org.ow2.asm</groupId>
            <artifactId>asm</artifactId>
            <version>6.2</version>
        </dependency>
    </dependencies>
</plugin>

Solution

  • Create a system.properties file in the root directory of your app, and put the following in it:

    java.runtime.version=10.0.2
    

    Commit it to Git and push again. For more info see Heroku'd Dev Center.