I'm using IntelliJ IDEA Ultimate 2019.3.1. Whenever I try to start any simple Java Maven project (may it be even a simple Hello World) I get the following error:
Error:java: error: release version 5 not supported
Running java --version
by terminal I get the following output:
openjdk 11.0.5 2019-10-15
OpenJDK Runtime Environment (build 11.0.5+10-post-Ubuntu-0ubuntu1.1)
OpenJDK 64-Bit Server VM (build 11.0.5+10-post-Ubuntu-0ubuntu1.1, mixed mode, sharing)
Running javac --version
by terminal I get the following output:
javac 11.0.5
Going to the Settings of the Java Compiler ( as suggested here ) I see this:
I tried editing the "Target bytecode version" to 1.8 but I get the following errors:
Error:(1, 26) java: package javafx.application does not exist
Error:(2, 20) java: package javafx.stage does not exist
Error:(4, 27) java: cannot find symbol
symbol: class Application
Error:(12, 23) java: cannot find symbol
symbol: class Stage
location: class Main
Error:(7, 9) java: cannot find symbol
symbol: method launch(java.lang.String[])
location: class Main
Error:(11, 5) java: method does not override or implement a method from a supertype
Changing it to version 1.11 I get this error instead:
Error:java: Source option 5 is no longer supported. Use 6 or later.
What do you think is the problem? How may I solve it?
SeeĀ https://stackoverflow.com/a/12900859/104891.
First of all, set the language level
/release versions
in pom.xml
like that:
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
Maven sets the default to 1.5 otherwise. You will also need to include the maven-compiler-plugin
if you haven't already:
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
</dependency>
Also, try to change the Java version in each of these places:
File -> Project structure -> Project -> Project SDK -> 11.
File -> Project structure -> Project -> Project language level -> 11.
File -> Project structure -> Project -> Modules -> -> Sources --> 11
In project -> ctrl + alt + s -> Build, Execution, Deployment -> Compiler -> Java Compiler -> Project bytecode version -> 11
In project -> ctrl + alt + s -> Build, Execution, Deployment -> Compiler -> Java Compiler -> Module -> 1.11.