Search code examples
javamavenheroku

heroku - system.properties and java version


I wanted to deploy my java 7 application to Heroku but I encountered some problems with java version.

I added system.properties file in my project root directory (where src and pom.xml are) with content java.runtime.version=1.7 but still I am getting something like this:

Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.0:compile (default-compile) on project lets-code: Fatal error compiling: invalid target release: 1.7

so I am a bit confused as to what to do next.


Solution

  • The default version of Java on Heroku is Java 6. You need to follow the Guidelines to make your maven project run on newer versions of the JVM (1.7 or 1.8). You already added the system.properties file to your project. However you probably did not updated the PATH as specified and maven tries to build your app using OpenJDK 6 which leads to the invalid target release exception.

    Updating the PATH should do the trick.