IntelliJ: Error:java: error: release version 5 not supported

JavaIntellij Idea

Java Problem Overview


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:

Java Compiler Settings

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?

Java Solutions


Solution 1 - Java

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.

Solution 2 - Java

Took me a while to aggregate an actual solution, but here's how to get rid of this compile error.

  1. Open IntelliJ preferences.

  2. Search for "compiler" (or something like "compi").

  3. Scroll down to Maven -->java compiler. In the right panel will be a list of modules and their associated java compile version "target bytecode version."

  4. Select a version >1.5. You may need to upgrade your jdk if one is not available.

enter image description here

Solution 3 - Java

By default, your "Project bytecode version isn't set in maven project.

It thinks that your current version is 5.

Solution 1:

Just go to "Project Settings>Build, Execution...>compiler>java compiler" and then change your bytecode version to your current java version.

Solution 2:

Adding below build plugin in POM file:

 <properties>
        <java.version>1.8</java.version>
        <maven.compiler.version>3.8.1</maven.compiler.version>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
    </properties>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>${maven.compiler.version}</version>
                <configuration>
                    <source>${java.version}</source>
                    <target>${java.version}</target>
                </configuration>
            </plugin>
        </plugins>
    </build>

Solution 4 - Java

I add the following code to my pom.xml file. It solved my problem.

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <maven.compiler.source>1.8</maven.compiler.source>
    <maven.compiler.target>1.8</maven.compiler.target>
</properties>

Solution 5 - Java

In my case it was enough to add this part to the pom.xml file:

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.0</version>
                <configuration>
                    <release>11</release>
                </configuration>
            </plugin>
        </plugins>
    </build>

Solution 6 - Java

I did everything above but had to do one more thing in IntelliJ:

Project Structure > Modules

I had to change every module's "language level"

Solution 7 - Java

If your are using IntelliJ, go to setting => compiler and change the version to your current java version.

Solution 8 - Java

The only working solution in my case was adding the following block to pom.xml:

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.8.0</version> <configuration> <release>12</release>
        </configuration>
        </plugin>
    </plugins>
</build>

Solution 9 - Java

You should do one more change by either below approaches:


1 Through IntelliJ GUI

As mentioned by 'tataelm':

Project Structure > Project Settings > Modules > Language level: > then change to your preferred language level


2 Edit IntelliJ config file directly

Open the <ProjectName>.iml file (it is created automatically in your project folder if you're using IntelliJ) directly by editing the following line,

From: <component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_5">

To: <component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_11">

As your approach is also meaning to edit this file. :)


Approach 1 is actually asking IntelliJ to help edit the .iml file instead of doing by you directly.

Solution 10 - Java

The solution to the problem is already defined in some of the answers. But there is still a need to express a detail. The problem is totally related to maven, and the solution is also in the pom.xml configuration. IntelliJ only reads maven configuration, and if the configuration has wrong information, IntelliJ also tries to use that.

To solve the problem, as expressed in the most of the answers, just add the below properties to the pom.xml of the project.

<properties> 
      <maven.compiler.source>1.8</maven.compiler.source> 
      <maven.compiler.target>1.8</maven.compiler.target> 
</properties>

After that, on the IntelliJ side, reimport maven configuration. To reimport the maven configuration, right click on pom.xml file of the project and select Reimport. Compiler version related information in IntelliJ preferences will be automatically updated according to the values in the pom.xml.

Solution 11 - Java

You only have to add these two lines in your pom.xml. After that, your problem will be gone.

<!--pom.xml-->
<properties>
    <maven.compiler.source>1.8</maven.compiler.source>
    <maven.compiler.target>1.8</maven.compiler.target>
</properties>

Solution 12 - Java

If you are using spring boot as a parent, you should set the java.version property, because this will automatically set the correct versions.

<properties>
   <java.version>11</java.version>
</properties>

The property defined in your own project overrides whatever is set in the parent pom. This overrides all needed properties to compile to the correct version.

Some information can be found here: https://www.baeldung.com/maven-java-version

Solution 13 - Java

I had the same issue but with a small difference. My error message was the following.

IntelliJ: Error:java: error: release version 16 not supported

So in Intellij go to

  • File
  • Settings
  • Build, Execution, Deployment
  • Compiler

In here there is field called "Project bytecode version". There the default value was 16, I changed it to 8 and everything worked fine.

Solution 14 - Java

Within IntelliJ, open pom.xml file.

Add this section before <dependencies> (if your file already has a <properties> section, just add the <maven.compiler...> lines below to that existing section):

<properties> 
   <maven.compiler.source>1.8</maven.compiler.source> 
   <maven.compiler.target>1.8</maven.compiler.target> 
</properties>

Solution 15 - Java

I've done most things you are proposing with Java compiler and bytecode and solved the problem in the past. It's been almost 1 month since I ran my Java code (and back then everything was fixed), but now the problem appeared again. Don't know why, pretty annoyed though!

This time the solution was: Right click to project name -> Open module settings F4 -> Language level ...and there you can define the language level your project/pc is.

No maven/pom configuration worked for me both in the past and now and I've already set the Java compiler and bytecode at 12.

Solution 16 - Java

You need to set language level, release version and add maven compiler plugin to the pom.xml

<properties>
  <maven.compiler.source>1.8</maven.compiler.source>
  <maven.compiler.target>1.8</maven.compiler.target>
</properties>

<dependency>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-compiler-plugin</artifactId>
  <version>3.8.1</version>
</dependency>

Solution 17 - Java

Found one more place to change, which actually fixed for me.

Project Structure -> < Select Module > Dependencies -> Module SDK < Select version from drop down >

enter image description here

Solution 18 - Java

  1. File->Settings

enter image description here

  1. From left side ->"Build, Execution, Deployment" ->"java compiler"

enter image description here

  1. choose the project that you work on and choose the java version you need

enter image description here

Solution 19 - Java

In IntelliJ, the default maven compiler version is less than version 5, which is not supported, so we have to manually change the version of the maven compiler.

We have two ways to define version.

First way:

<properties>
  <maven.compiler.target>1.8</maven.compiler.target>
  <maven.compiler.source>1.8</maven.compiler.source>
</properties>

Second way:

<build>
  <plugins>
    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.8.0</version>
        <configuration>
            <source>8</source>
            <target>8</target>
        </configuration>
    </plugin>
  </plugins>
</build>

Solution 20 - Java

guys, I have also encountered this problem after having so much research on this issue I found 3 solutions to resolve this issue

  1. Add these properties in your pom.xml; //Sorry for the formatting

<properties><java.version>1.8</java.version<maven.compiler.version>3.8.1</maven.compiler.version<maven.compiler.source>1.8</maven.compiler.source<maven.compiler.target>1.8</maven.compiler.target><java.version>11</java.version></properties>

  1. Delete everything in the target byte version, you can find this in the java compiler setting of the IntelliJ

Remove everything below target byte version make it empty

  1. Find the appium version you are using in the dependency. here I am using 7.3.0 find the version of the appium you are using in the dependency in pom.xml

Then write your version in the target byte version in java compiler enter image description here

ENJOY THE CODE>>>HOPE IT WORKED FOR YOU

Solution 21 - Java

For me in Intelij click on File -> Project Structure -> select the modules in language level select 11 - Local variable syntax for lambda parameters, click em aply.

Run in terminal mvn clean install.

Its solved my problem.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionRobb1View Question on Stackoverflow
Solution 1 - JavaKonstantin AnnikovView Answer on Stackoverflow
Solution 2 - JavaborisveisView Answer on Stackoverflow
Solution 3 - JavaArjun MaratiView Answer on Stackoverflow
Solution 4 - JavaJéssica MachadoView Answer on Stackoverflow
Solution 5 - JavaKrzysztof TomaszewskiView Answer on Stackoverflow
Solution 6 - JavatataelmView Answer on Stackoverflow
Solution 7 - JavaSikhumbuzo SitholeView Answer on Stackoverflow
Solution 8 - JavaMuhammed GülView Answer on Stackoverflow
Solution 9 - JavagarykwwongView Answer on Stackoverflow
Solution 10 - JavaayhanView Answer on Stackoverflow
Solution 11 - JavaMehedi AbdullahView Answer on Stackoverflow
Solution 12 - JavaV JansenView Answer on Stackoverflow
Solution 13 - JavaRuchin AmaratungaView Answer on Stackoverflow
Solution 14 - JavaAli ShahView Answer on Stackoverflow
Solution 15 - JavaGiorgos ArgyriouView Answer on Stackoverflow
Solution 16 - JavaUserView Answer on Stackoverflow
Solution 17 - JavaManishView Answer on Stackoverflow
Solution 18 - JavaVladiView Answer on Stackoverflow
Solution 19 - JavaManish JangidView Answer on Stackoverflow
Solution 20 - JavaThe_real_codderView Answer on Stackoverflow
Solution 21 - JavaRenato VasconcellosView Answer on Stackoverflow