Scala sbt run - "Unsupported major.minor version 52.0"
It turned out that there was a mismatch in the JRE version. In the IntelliJ project settings the project SDK was set to be Java 1.8 (on my local machine), whereas JRE 1.7 was installed on the Ubuntu system (an EC2 instance).
In Ubuntu 14.04, the OpenJDK 1.8 is not available by default so the following repository must be added manually. Then the OpenJDK can be installed.
sudo add-apt-repository ppa:openjdk-r/ppa
sudo apt-get update
sudo apt-get install openjdk-8-jre
The default Java version in the system can be changed by running the following command.
sudo update-alternatives --config java
Once I installed openjdk-8-jre
and adjusted the default Java version in the system, the sbt run
command ran without any issue.
I encountered the same proble with CentOS-7.6, here is my solution:
- run
vim /etc/profile
in command line, check your Environment variable to find the jdk version, change it to jdk-1.8. Save and quit safely. example picture - run
/usr/sbin/alternatives --config java
, choose version-1.8. - run
/usr/sbin/alternatives --config javac
, also choose version-1.8. - run
source /etc/profile
to make the settings work.
By doing the four steps, I was able to run command sbt again without orror.sbt picture
Update to correct java version and compile again. It should work fine
I am using a Mac and trying to learn Scala by following a simple Scala tutorial. I got this error when I am trying to run the app.
Reason: My installed java version was 8. But on my Terminal the version I was using was 7.
Fix: I updated the java version to the newest version and then it worked.