Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

wrong java version in heroku

I've created a spring boot app and would like to run it on heroku. My app is compiled using java 9.

As I'm deploying it to heroku using the CLI plugin I'm getting

Exception in thread "main" java.lang.UnsupportedClassVersionError: io/safeblocks/firewall/FirewallApplication has been compiled by a more recent version of the Java Runtime (class file version 53.0), this version of the Java Runtime only recognizes class file versions up to 52.0

Clearly this means java versions mismatch. I added the system.properties file to my resources folder with the property java.runtime.version=9 as explained but still getting the same error.

As I run the command heroku run java -version --app myApp I'm getting:

openjdk version "1.8.0_171-heroku"
OpenJDK Runtime Environment (build 1.8.0_171-heroku-b11)
OpenJDK 64-Bit Server VM (build 25.171-b11, mixed mode)

So it seems heroku is still not picking up the required java version. Any ideas?

like image 614
forhas Avatar asked Nov 08 '22 04:11

forhas


1 Answers

I see you added the system.properties file to your resources folder, I did the same mistake. The file system.properties must be placed under the root folder of your project.

The content of your file is correct: java.runtime.version=9

After you moved the file to the root folder, commit your changes and do: git push heroku master

Everything should be fine then.

like image 174
jordivilagut Avatar answered Nov 14 '22 22:11

jordivilagut