Error java error release version 5 not supported maven

How to fix the Release Version 5 Not Supported error in IntelliJ

What do you do when you create a new Maven Java project, and when you run it, you get the following error:

Error:java: error: release version 5 not supported

Sometimes the error could also read as follows:

java: Source option 5 is no longer supported. Use 6 or later.

Luckily for us, the solution is exactly the same!

Solution#

Open the project’s pom.xml file and add the following snippet:

Now open the Maven side-panel, and click the Report All Maven Projects button.

You can now successfully run your new Maven Java project.

Additional Notes#

The release version 5 not supported error is quite common with newly created projects.

The java error is frequently seen in IntelliJ after a new Maven project has begun and full setup has not been completed.

By default, the project bytecode version is not actually set in Java maven projects.

Therefore it believes that your current version is set to 5.

Open up Project Settings > Build , Execution …> compiler > java compiler and change your bytecode version to your current java version.

An alternative solution#

If the above does not work for you when trying to solve the java error: release version 5 not supported in IntelliJ, you can attempt the following alternative:

  1. Open the IntelliJ preferences dialog.
  2. Filter the navigation items by typing compiler .
  3. Move to the Maven->Java Compiler section.
  4. In the right hand configuration panel, there is a list of modules and their accompanying Java compile versions. This is called the target bytecode version .
  5. Finally select a version bigger than 1.5.

Note that if there is no version greater than 1.5 available in the above list, then you will need to upgrade your Java Development Kit (JDK) on the local machine.

Once all of these steps have been completed, you may also want to go to the Project Structure contextual menu and select Modules . Under here you will have the option to change each of the module’s language level .

You can also always just update your pom.xml to contain the following:

This will fix your java: error: release version 5 not supported problem encountered while trying to run, or execute a Maven Java application in IntelliJ IDEA.

Источник

IntelliJ — Error:java: release version 5 not supported

A common error in IntelliJ when attempting to run a new Java maven project is Error:java: release version 5 not supported . Here are 3 techniques to resolve this. Try them in order. If one doesn’t resolve the issue, try the next.

1. Update Java Compiler

  • Go to IntelliJ IDE menu item (or File on Windows) -> Preferences -> Build, Execution, Deployment -> Java Compiler
  • Delete value under Target bytecode version, then click OK
  • Refresh maven
  • Try running again. If problem persists, continue on to number 2 below

2. Update SDK Version

  • Go to File -> Project Structure -> Project Settings -> Project. Make sure you have the correct Java version selected. It should be the same as the one you downloaded
  • Also on this same panel, go to Platform Settings -> SDKs. Make sure you have the correct Java version selected
  • Click OK
  • Refresh maven
  • Try running again. If problem persists, continue on to number 3 below

3. Add property to pom.xml

  • Within IntelliJ, open pom.xml file
  • Add this section before (If your file already has a section, just add the lines below to that existing section):
  • Change the x in 1.8 to your Java version. For example, if you’re using Java 13, change 1.8 to 1.13
  • Refresh maven

Источник

Proper solutions for error “java: release version 5 not supported”

This article is meant as an extension to Angie Jones’ “IntelliJ – Error:java: release version 5 not supported”.

In her article Angie suggest solutions to IntelliJ IDEA showing the error message “release version 5 not supported”. The first two options work within IDEA, but are not sustainable as you will learn later. The last option tackles the actual problem, but only for Maven based builds. To recap, the correct solution for Maven based builds (see also Maven Compiler Plugin), is as follows:

I would like to give some background on the problem and suggest to solve the problem differently.

What is the actual problem?

To find a proper solution for all kind of Java projects, regardless of the build tool, let’s dive into the actual problem.

In its more than 20 years, Java went through several major versions. Each of those introduced a new version of the binaries format and sometimes also language features (e.g. enums in Java 5, lambdas in Java 8, modules in Java 9, var in Java 10, HTTP-2 client Java 11… ). Yet, Java and its virtual machine are highly backwards-compatible. You can take 20 years old binaries and they will run with the latest version of Java just fine (exceptions apply).

The Java compiler, which generates binary files from Java source files supports cross-compiling to various language levels, that is creating these binaries in formats of different Java versions. However, sometimes support for older language levels is dropped. Since Java 9, the compiler cannot generate Java 5 binaries anymore. If the compiler now runs – directly or indirectly through a build tool – with a target version of Java 5 it will show the error message release version 5 not supported.

The root problem for the error message is, that the Java Development Kit (JDK) is too new to generate old binaries.

Proper Solutions

So, your JDK is too new to generate Java 5 binaries. There are two solutions to tackle this problem.

Use an older JDK

As previously mentioned, JDK 9 dropped the support for cross-compiling to Java 5 binaries. This means, as long as you use a JDK 8 or below, you can actually create Java 5 binaries. However, this method is NOT recommended. There should be no reason to stick to Java 5 in a production runtime environment. JDK 5 is not supported since 2015 and security patches are not provided anymore.

Change the desired target language level

Instead of cross-compiling to Java 5 binaries, you should create binaries, that match the version of the Java runtime environment in production. This should be at least Java 8 until 2023 to get security patches. See also Java version history on Wikipedia. However, I recommend to use Java 11 to make use of various new features introduced in-between and staying on an LTS version at the same time.

So, how to change the target version then?

Maven-based projects

For very good reasons Maven is still vastly used in the Java ecosystem. However, Maven is quite old and so are some of the defaults as well. One of which is the language level, that defaults to Java 1.5, regardless of the JDK you use.

In plain Maven projects you can paste the above mentioned code into your build configuration file pom.xml to set the target language level.

In SpringBoot projects, the code slightly changes to

After changing the pom.xml you need to Reimport All Maven Projects in IntelliJ IDEA. The easiest way to do it, is to press cmd+shift+A (shift+ctrl+A on Windows/Linux) and then simply start typing.

Search in actions for

Plain IntelliJ IDEA projects

If you did not choose any build system for your Java projects in IntelliJ, you simply need to make sure, the language level is configured according to the project’s JDK. You can do this in the project structure settings. Press cmd+shift+A and start typing to open the settings.
As soon, as you use an JDK 9+ you need to change the target level accordingly.

Project Structure

  • Java 9-11: Target level Java 6
  • Java 12+: Target level Java 7

Conclusion

In this post I explained the root cause for the error message release 5 version not supported.
One can work around this problem locally by changing IntelliJ project settings. However, if you wanted to solve the problem properly, you need to change the project’s build configuration file. Otherwise on the next import into IntelliJ you will need to change it again. Also, the build might behave differently on each computer. The CI server and others, who didn’t change their IntelliJ IDEA settings, will continue to produce Java 5 binaries. Persisting the language level in the build configuration file will produce stable and foreseeable results across machines.

Источник

How to fix Intellij – Maven projects – Java release Version is not supported and Java language level errors

Recently I created a new Maven project in Intellij Idea 2019 and when I compiled it, I got the following error as shown in the below screenshot.

Intellij Maven project language level error screenshot

Intellij Maven project language level error screenshot

The error message was: Error:java: error: release version 5 not supported. There can be many other issues such as java:string in switch are not supported, java:diamond operator is not supported in -source 1.5 and so on.

What is the issue

This happens because Maven sets the default Java version to 1.5 which is very old. According to the Maven website: “Apache Maven Compiler Plugin
The Compiler Plugin is used to compile the sources of your project. Since 3.0, the default compiler is javax.tools.JavaCompiler (if you are using java 1.6) and is used to compile Java sources. If you want to force the plugin using javac, you must configure the plugin option forceJavacCompilerUse. Also note that at present the default source setting is 1.5 and the default target setting is 1.5, independently of the JDK you run Maven with. If you want to change these defaults, you should set source and target as described in Setting the -source and -target of the Java Compiler.” To fix the issue we have to specify which Java version is to be used.

This is the solution

According to the Maven Website, what we have to do is to add the following lines of code to the pom.xml file. Under source and target I have used Java version 11, change it to the version of java you are using.

   org.apache.maven.plugins maven-compiler-plugin 3.8.1 11 11     
  4.0.0 your project group ID your project artifact ID 1.0-SNAPSHOT   org.apache.maven.plugins maven-compiler-plugin 3.8.1 11 11      

In Intellij, you can check which version of Java you are using by going to File -> Project Structure and under Project settings, Project as shown in the below screenshot.

Intellij Project Settings

Intellij Project Settings

Источник

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

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:

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?

This question is related to java intellij-idea

Источник

Читайте также:  Php путь от www
Оцените статью