Heroku unable to detect java 11

Viewed 1144

I am trying to deploy a java jar to heroku with heroku maven plugin. I am using java 11 so I have added system.properties in the root folder(where pom.xml is present) and set java.runtime.version=11. However it doesn't seem to be working !

My plugin :

            <plugin>
                <groupId>com.heroku.sdk</groupId>
                <artifactId>heroku-maven-plugin</artifactId>
                <version>3.0.1</version>
                <configuration>
                    <includeTarget>false</includeTarget>
                    <includes>
                        <include>${project.build.directory}/${project.build.finalName}.jar</include>
                    </includes>
                    <processTypes>
                        <web>java $JAVA_OPTS -jar ${project.build.directory}/${project.build.finalName}.jar</web>
                    </processTypes>
                </configuration>
            </plugin>

When I do git push heroku master it starts build process using jdk 8.


remote: Building source:
remote: 
remote: -----> Java app detected
remote: -----> Installing JDK 1.8... done
remote: -----> Installing Maven 3.6.2... done
remote: -----> Executing Maven
remote:        $ mvn -DskipTests clean dependency:list install

Eventually build fails with error :

 Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.0:compile (default-compile) on project ImpactHub_bot: Fatal error compiling: invalid flag: --release -> 

How do I set jdk verison to 11 ? I have also tried adding ${java.version} to configuration but it didn't help

1 Answers

That's exactly how you are specifying the Java version, see: https://devcenter.heroku.com/articles/java-support#specifying-a-java-version

You can specify a Java version by adding a file called system.properties to your application.

Set a property java.runtime.version in the file:

java.runtime.version=11

I used it in my project as well and it is working.


Make sure your system.properties is saved as All Files. Furthermore it should be at the root folder of your git repo.
It might have a .txt ending. If that fails open a Support Ticket with Heroku.

Related