Error java source option 5 is no longer supported use 6 or later 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.

  1. How to Reverse an Integer in Java
  2. Reverse a String in-place using Java
  3. Check if a Java array Contains Duplicates
  4. The Array Height Checker Problem in Java
  5. Find the Squares of a Sorted Array in Java
  6. Sorting a Java Array by Parity
  7. Remove Duplicates from Sorted Array in Java
  8. Replace Elements with Greatest Element on Right Side using Java
  9. The Valid Mountain Array Problem using Java
  10. Find Numbers with Even Number of Digits using Java

Источник

Introduction

When we create Maven projects using artifacts and try to run them, we sometimes get the following error. Source option 5 is no longer supported. Use 7 or later. In this post, let’s see the steps involved to fix the error in the Maven project.

The error (Source option 5 is no longer supported) is common when we create a Maven project from the old archetypes. In this case, we need to specify the source and target version to the Maven compiler. We can specify these properties in Maven pom.xml file.

Error

[ERROR] COMPILATION ERROR : [INFO] ------------------------------------------------------------- [ERROR] Source option 5 is no longer supported. Use 7 or later. [ERROR] Target option 5 is no longer supported. Use 7 or later. [INFO] 2 errors [INFO] ------------------------------------------------------------- [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 3.025 s ------------------------------------------------------------------------ [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin: 3.1:testCompile (default-testCompile) on project AppiumProject: Compilation failure: Compilation failure: [ERROR] Source option 5 is no longer supported. Use 7 or later. [ERROR] Target option 5 is no longer supported. Use 7 or later.

Source option 5 is no longer supported

Fix

The fix for the problem is to use the latest Java environment for the project that is above JDK 7 or Later.

Identify the JDK version installed on your machine or the version the IDE workspace uses. Update the project build path with the latest library settings.

1.5 Java Compiler

Right-click Project properties >> Java Compiler.

Change the JDK compliance parameters from 1.5 -> 1.7 or above.

Click on the Execution Environments link and select the latest or suitable JDK above JDK 1.7

Java Execution Environments

Click on Apply and Close button.

Maven POM.xml

Follow the below steps to avoid this error in the Maven project,

  • Check the Java compiler version. (Project-specific settings)
  • Workspace settings. (Configure Workspace settings)
  • Project build path.
  • Maven POM.xml build file.

Jenkins Error Source and Target

Examples

For example, to specify JDK 8 we can add the properties like the below to the POM.xml file:

JDK 14

Change the Java compiler and the project build path. After the changes specify the JDK version in the POM.xml Maven build file.

For example, specify the JDK 14 to the Maven pom.xml.

source option 5 is no longer supported

Sample pom.xml file

Sample pom.xml file with JDK 14 version

 4.0.0 com.testingdocs TestNGTutorials 0.0.1-SNAPSHOT 14 14   org.seleniumhq.selenium selenium-java 4.0.0-alpha-7  org.seleniumhq.selenium selenium-firefox-driver 4.0.0-alpha-7  org.seleniumhq.selenium selenium-edge-driver 4.0.0-alpha-7  org.testng testng 6.8      org.apache.maven.plugins maven-surefire-plugin 3.0.0-M5     

Verify the fix

Run the Maven project. The error should be fixed now.

After changing the settings and adding the properties information to the pom.xml file. Verify by running the project. In Eclipse IDE, to build the project choose the option

Maven Tutorial

Maven tutorial on this website:

For more information on the Maven build tool, visit the official website:

Источник

Error «Source option 5 is no longer supported. Use 6 or later» on Maven compile

As an example, let us use “–release” to target Java 8: There are many IDEs are available for Java development Let us see how we can overcome “UnsupportedClassVersionError” in Eclipse Selecting JRE using Java Build Path->Installed JRE Java compiler level selection : Java compiler selection Maven We can control the version of Java when we build and package a file in Maven. Hence, it is important to note the java versions Get the installed java version : java –version (In command prompt(windows), we can give) Check java version Fixing the program via command line :

Error «Source option 5 is no longer supported. Use 6 or later» on Maven compile

What helped me was these lines in pom.xml file

Language Level

Also in one of my projects, in addition to all of answers above, another try works: Just change Language level in Modules section of Project Structure [image below] [ ]1

I had same issue, the problem is with properties. Check your JavaSE version in your project, it will be displayed beside JRE System Library folder in your project. If it is 1.5, then it will throw an error. Most probably you will have a updated version, so check the version and update it. I have updated it below based on your code.

Request method ‘post’ not supported thymeleaf Code, // FOR DELETE METHODS THIS CONFIG MAY BE NECESSARY IN YOUR app.properties: spring.mvc.hiddenmethod.filter.enabled=true

How to fix this Error with JAVA Rest Assure

Downgrading to JDK 11 solved this issue for me

This issue currently is not fixed. See this bug report for details.
It seams that JDK14 tries to load a constructor from org.codehaus.groovy.vmplugin.v7.Java7 using Reflection, but the constructor does not exist for JDK14.
This is also because Java publishes a new major version every 6 months!

A solution might be to downgrade your major version to JDK13, or to the LTS version that will be supported until 2026.
Another solution might be to wait until this bug is fixed.

Spring — Maven is not using Java 11, I had he same problem even the correct JAVA-Version 11 and JAVA_HOME variable was set. Switching to another Java-Vendor from AdoptOpenJDK to Corretto solved it.. You can use SDKMAN to change easily and quick between different Java-Versions and vendors. (JAVA_HOME variable will …

How to Fix java.lang.UnsupportedClassVersionError in Java?

The UnsupportedClassVersionError is a sub-class of the LinkageError and thrown by the Java Virtual Machine (JVM). When a class file is read and when major and minor version numbers are not supported, this error is thrown, and especially during the linking phase, this error is thrown

A sample snapshot of UnsupportedClassVersionError

Situations when the error is thrown :

When we tried to compile a program using a higher version of Java and execute it using a JVM of a lower version, this error is thrown. But the reverse case is not true.

Hence, it is important to note the java versions

Get the installed java version :

java –version (In command prompt(windows), we can give)

Fixing the program via command line :

In order to overcome the UnsupportedClassVersionError, we can either compile our code for an earlier version of Java or run our code on a newer Java version. It is about our choice of decision only. If a third-party library is used then, it is better to run on a newer java version and if it is for distribution, it is best to compile to an older version.

Using JAVA_HOME Environment Variable :

While doing Java programs, always it is good to set JAVA_HOME and setting that value in path

We can check that in command prompt in the below way also

C:\Windows\system32>echo %JAVA_HOME% C:\Program Files\Java\jdk-9.0.4

Requirements to run a java program on a new JRE:

Move to the directory and locate the bin directory. For example, if the JRE is in location like

C:\Program Files\Java\jdk-11.0.2, then navigate till C:\Program Files\Java\jdk-11.0.2\bin
java // Even we can give filename with full package

Requirements to run a java program on an older JRE :

C:\Program Files\Java\jdk1.8.0_31\bin\javac

In order to ensure compatibility, we can point “-bootclasspath” at the rt.jar of the targeted JRE:

javac -bootclasspath «C:\Program Files\Java\jdk1.8.0_31\jre\lib\rt.jar» \ -source 1.8 -target 1.8

[Applicable mainly to JDK 8 and lower]

But in JDK 9, the “–release” parameter was added to replace “-source” and “-target”.

The “–release” option supports targets 6, 7, 8, 9, 10, and 11. As an example, let us use “–release” to target Java 8:

There are many IDEs are available for Java development

Let us see how we can overcome “UnsupportedClassVersionError” in Eclipse

Selecting JRE using Java Build Path->Installed JRE

Java compiler level selection :

We can control the version of Java when we build and package a file in Maven. When using Java 7 or older, we set the source and target for the compiler plugin.

Let’s set the source and target using compiler plugin properties:

–release option added in Java 9

Conclusion :

By setting the environment changes either via command-line way or via IDE way or via Maven way, we can overcome “unsupportedclassversion”.

Search Code Snippets, Features Reviews Code Answers Search Code Snippets Pricing FAQ Welcome Browsers Supported Grepper Teams Documentation Adding a Code Snippet Viewing & Copying Snippets

Not supported for DML operations delete hibernate

Not supported for DML operations

public interface LimitRepository extends JpaRepository < @Transactional @Modifying @Query("delete from CLimit l where l.trader.id =:#") void deleteLimitsByTrader(@Param("trader") CTrader trader); >

Java — Maven 3.8.0 Compiler, Ensure JAVA_HOME is set to C:\Program Files\Java\jdk-11 In your pom.xml add » 11 » and reference $ where applicable.

Источник

Читайте также:  Text size html inline
Оцените статью