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

Error: java: error: release version 5 not supported

Author

Date

Category

This is not the first time this problem, I don’t remember how I managed to solve it, it seems that I was creating a new project.
Krch is a class, there is a method main () and there is System.out.println ("Hello");
When calling main, it throws out a compilation error and Error: java: error: release version 5 not supported
What could be the problem and how to solve it?

Problem method:

public static void main (String [] args) {
  System.out.println ("Hello");
}

Screen of project settings:


Answer 1, authority 100%

If you are using IntelijIDEA, then carefully check what you have configured in Project Structure :

Project Structure & gt; & gt; Project & gt; & gt; Project SDK;
Project Structure & gt; & gt; Project & gt; & gt; Project language level;
Project Structure & gt; & gt; Modules & gt; & gt; Dependencies & gt; & gt; Module SDK;
Project Structure & gt; & gt; Modules & gt; & gt; Sources;
Project Structure & gt; & gt; SDKs;

Because the java: error: release version 5 not supported error can occur when the compiler version in the IDE settings:

File & gt; & gt; Settings & gt; & gt; Build, Execution, Deployment & gt; & gt; Compiler & gt; & gt; Java Compiler & gt; & gt; project bytecode version & gt; & gt; Per-module bytecode version

is not the same as in Project Structure .

Also, if you are building a Jar and have successfully built artifacts, make sure that in Run / Debug Configurations , the default JRE version also matches the project version.

If you are using the Maven builder, you can explicitly change the version of the project using the POM by writing the following lines:

& lt; maven.compiler.source & gt; 1.8 & lt; /maven.compiler.source>
& lt; maven.compiler.target & gt; 1.8 & lt; /maven.compiler.target>

Or in a plugin:

& lt; build & gt;
  & lt; plugins & gt;
    & lt; plugin & gt;
      & lt; groupId & gt; org.apache.maven.plugins & lt; / groupId & gt;
      & lt; artifactId & gt; maven-compiler-plugin & lt; / artifactId & gt;
      & lt; configuration & gt;
        & lt; source & gt; 1.8 & lt; / source & gt;
        & lt; target & gt; 1.8 & lt; / target & gt;
      & lt; / configuration & gt;
    & lt; / plugin & gt;
  & lt; / plugins & gt;
& lt; / build & gt;

Sometimes the settings in the Project Structure and the compiler version can get confused, so before the next build, check that everything matches your main version of the project.


Answer 2, authority 36%

Two months have already passed, the author probably does not need help, but this may help those who are looking for a similar answer.
Preferences – & gt; Build, Execution, Deployment – & gt;
Java Compiler: Project bytecode version: 6
Target bytecode version: 6
Try changing to the 6th version, it helped me!


Answer 3, authority 17%

file- & gt; settings- & gt; search: Java Compiler – & gt; Target bytecode version: 11


Answer 4, authority 3%

From official compiler documentation :

Beginning with JDK 9, javac no longer supports -source release
settings less than or equal to 5. If settings less than or equal to 5
are used, then the javac command behaves as if -source 6 were
specified.

So, as you have already correctly suggested, you need to go through the settings (both the IDE itself and the project) and check that the language level and target bytecode version parameters are set everywhere at least 6. And if the project uses a collector, then build -the file must be checked for the appropriate parameters.


Answer 5, authority 3%

& lt; plugins & gt;
      & lt; plugin & gt;
        & lt; groupId & gt; org.apache.maven.plugins & lt; / groupId & gt;
        & lt; artifactId & gt; maven-compiler-plugin & lt; / artifactId & gt;
        & lt; version & gt; 3.8.0 & lt; / version & gt;
        & lt; configuration & gt;
          & lt; release & gt; 11 & lt; / release & gt;
        & lt; / configuration & gt;
      & lt; / plugin & gt;
    & lt; / plugins & gt; 

Answer 6

I checked all the settings I found, added version 14 to the pom.xml, but it didn’t help.
In my case, the problem turned out to be in the ProjectName.iml file, where it was indicated

& lt; module type = "JAVA_MODULE" version = "4" / ​​& gt;

I replaced 4 with 14, it worked.

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions