3

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>
jMan
  • 587
  • 1
  • 8
  • 23
  • https://stackoverflow.com/questions/53604111/heroku-cannot-deploy-java-11-spring-boot-app My thread, still haven't figure it out and I tried a lot of things, nothing worked. It has to be something else. – Manuel Pap Dec 26 '18 at 11:33
  • @valkon in my case `system.properties` was in the `src` directory instead of the root/highest level directory – jMan Dec 26 '18 at 17:02

1 Answers1

5

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.

codefinger
  • 10,088
  • 7
  • 39
  • 51
  • Thanks, I now have a different problem but moving my `system.properties` file from `resources` to the root/highest level directory has fixed the JDK and made Heroku run the app – jMan Dec 26 '18 at 16:59
  • I assumed `system.properties` would go in the same place as `application.properties` which is [recomended to go in src/main/resources](https://stackoverflow.com/a/38775319/7394417) – jMan Dec 26 '18 at 17:06