Eclipse Maven and Java 8 problems - java

I moved from simple web app to maven web app and with Eclipse Neon I encountered a frustrating problem: after I add in pom.xml the specification to use Java 8 or 7, it doesn't work.
To verify if it works I write a simple class where I use a try(expression) declaration.
What should I have to do to use Java 8 in maven (I have installed and it works in normal web app)?
The code of pom.xml is this:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.webdata</groupId>
<artifactId>WebParser</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>WebParser</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>net.sourceforge.htmlunit</groupId>
<artifactId>htmlunit</artifactId>
<version>2.23</version>
</dependency>
</dependencies>
</project>

First, your JAVA_HOME must point to a JDK 1.8.
Else if is not the case, you must specify a JDK 1.8 as source and target in the compiler configuration of your pom.xml in this way :
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
<compilerVersion>1.8</compilerVersion>
<fork>true</fork>
<executable>D:\jdk1.8\bin\javac</executable>
</configuration>
</plugin>
Then, in eclipse, you must check in Preferences that :
Java->Installed JREs has a 1.8 JRE/JDK installed.
You could set the following as default if you want to use the 1.8 for any new created projects in your Eclipse :
Java->Installed JREs : select the 1.8.
Java->Compiler : select the JDK compiler compliance level to 1.8.
If the default preferences don't use 1.8 compilation compliance and JDK/JRE or that the project was created outside from this Eclipse with preferences set to 1.8 compilation compliance and JDK/JRE, you should check and maybe adjust properties of your Eclipse project
To do it, go in the properties of your project, then Java Build Path and in the Libraries tab. You must check that the JRE System Library uses Java 1.8. If it is not the case, remplace it with the 1.8 version.
When it is done, always in the properties of your project, go to Java Compiler and check that you use JDK compiler compliance with Java 1.8.
It should work.

It's funny :))
I searched 3-4 hours and I tried few methods and only after I asked here I found the solution :)
Right click on the project -> Properties -> Java Compiler -> uncheck 'Use compilance from execution...' and choose '1.8'

In pom.xml, defined this maven.compiler.source properties to tell Maven to use Java 8 to compile the project.
Maven Properties Java 8
<properties>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.source>1.8</maven.compiler.source>
</properties>
Compiler Plugin - Alternative, configure the plugin directly.
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>

This worked for me:
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
as mentioned here -> maven-compiler-plugin
Don't forget to update Maven project -> Alt + F5.

Related

Why JRE Library is changed after Maven Update in Eclipse?

I'm an Intellij user and now I need to use Eclipse to create a Maven web app. So I installed Eclipse, I added Tomcat and all. And I want to use Java 8 for my projects, but I have a problem because I try to change JRE System Library from 1.7 to 1.8, and when I do Maven -> Update Project it becomes 1.7. And I don't understand why.
So I create a Maven project and I choose the webapp archetype from org.apache.maven and at the beginning my project has JRE System Library 1.7
After that I try to choose it like this:
After that the JRE System Library becomes 1.8:
After that I do right click Maven -> Update project and the JRE System Library becomes 1.7:
Why the JRE Library is changed from 1.8 to 1.7 after Maven update? And what should I do to have JRE System Library 1.8?
This is my pom:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.abc</groupId>
<artifactId>firstwebproj</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>firstwebproj Maven Webapp</name>
<!-- FIXME change it to the project's website -->
<url>http://www.example.com</url>
<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>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<finalName>firstwebproj</finalName>
<pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
<plugins>
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>3.1.0</version>
</plugin>
<!-- see http://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_war_packaging -->
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.2</version>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.1</version>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>3.2.2</version>
</plugin>
<plugin>
<artifactId>maven-install-plugin</artifactId>
<version>2.5.2</version>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
Thanks in advance!
Look at your first picture. In the greyed out "Execution Environment" choice, the textfield has the content "JavaSE-1.7 (jdk1.8.0_201)". That JDK version is the same one you're trying to set it to use, but you have that JDK distro associated with Java SE 1.7.
In Eclipse Preferences, go to "Installed JREs", but go to the subfolder of that, "Execution Environments". In the left-hand list, you will see entries for "JavaSE-1.7" and hopefully "JavaSE-1.8". When you click each one of those, the right-hand list will populate with any available JDK/JRE installations.
You need to make sure that when you select "JavaSE-1.7", that NONE of the JDK 1.8 instlalations are checked in the right-hand list, and when you select "JavaSE-1.8, you have the desired JDK 1.8 distribution checked in the right-hand list.

Team City Build Failed : diamond operator is not supported in -source 1.6 [duplicate]

I wrote some Maven code in Netbeans that has approximately more than 2000 lines. When I compile it on Netbeans, everything is fine, but if I want to run it on command line, I will get these errors:
generics are not supported in -source 1.3
(use -source 5 or higher to enable generics)
ArrayList<ArrayList<Integer>> list = new ArrayList<ArrayList<Integer>>();
generics are not supported in -source 1.3
(use -source 5 or higher to enable generics)
HashSet<Double> resid_List = new HashSet<Double>(Arrays.asList(resid_val));
generics are not supported in -source 1.3
(use -source 5 or higher to enable generics)
List<Integer> ind_ovlpList = new ArrayList<Integer>(Arrays.asList(ind_ovlp));
generics are not supported in -source 1.3
(use -source 5 or higher to enable generics)
public class ColumnComparator implements Comparator<double[]> {
annotations are not supported in -source 1.3
(use -source 5 or higher to enable annotations)
#Override
I tried to use Java 1.3.1, compiler errors, but I got more errors. I found from other posts that I should modify pom.xml, but I do not know how. Here is my pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.mycompany</groupId>
<artifactId>mavenmain</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>mavenmain</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>gov.nist.math</groupId>
<artifactId>jama</artifactId>
<version>1.0.2</version>
</dependency>
</dependencies>
</project>
It would be great if you can help me!
maven-compiler-plugin it's already present in plugins hierarchy dependency in pom.xml. Check in Effective POM.
For short you can use properties like this:
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
I'm using Maven 3.2.5.
<project>
[...]
<build>
[...]
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>(whatever version is current)</version>
<configuration>
<!-- or whatever version you use -->
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
[...]
</build>
[...]
</project>
See the config page for the maven compiler plugin:
http://maven.apache.org/plugins/maven-compiler-plugin/examples/set-compiler-source-and-target.html
Oh, and: don't use Java 1.3.x, current versions are Java 11 or 17.
Generally you don't want to value only the source version (javac -source 1.8 for example) but you want to value both the source and the target version (javac -source 1.8 -target 1.8 for example).
Note that from Java 9, you have a way to convey both information and in a more robust way for cross-compilation compatibility (javac -release 9).
Maven that wraps the javac command provides multiple ways to convey all these JVM standard options.
How to specify the JDK version?
Using maven-compiler-plugin or maven.compiler.source/maven.compiler.target properties to specify the source and the target are equivalent.
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
and
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
are equivalent according to the Maven documentation of the compiler plugin
since the <source> and the <target> elements in the compiler configuration use the properties maven.compiler.source and maven.compiler.target if they are defined.
source
The -source argument for the Java compiler.
Default value is: 1.6.
User property is: maven.compiler.source.
target
The -target argument for the Java compiler.
Default value is: 1.6.
User property is: maven.compiler.target.
About the default values for source and target, note that
since the 3.8.0 of the maven compiler, the default values have changed from 1.5 to 1.6.
<release> tag — new way to specify Java version in maven-compiler-plugin 3.6
You can use the release argument :
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<release>9</release>
</configuration>
</plugin>
You could also declare just the user property maven.compiler.release:
<properties>
<maven.compiler.release>9</maven.compiler.release>
</properties>
But at this time the last one will not be enough as the maven-compiler-plugin default version you use doesn't rely on a recent enough version.
The Maven release argument conveys release to the Java compiler to access the JVM standard option newly added to Java 9, JEP 247: Compile for Older Platform Versions.
Compiles against the public, supported and documented API for a
specific VM version.
This way provides a standard way to specify the same version for the source, the target and the bootstrap JVM options.
Note that specifying the bootstrap is a good practice for cross compilations and it will not hurt if you don't make cross compilations either.
Which is the best way to specify the JDK version?
Java 8 and below
Neither maven.compiler.source/maven.compiler.target properties or using the maven-compiler-plugin is better.
It changes nothing in the facts since finally the two ways rely on the same properties and the same mechanism : the maven core compiler plugin.
Well, if you don't need to specify other properties or behavior than Java versions in the compiler plugin, using this way makes more sense as this is more concise:
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
Java 9 and later
The release argument (third point) is a way to strongly consider if you want to use the same version for the source and the target.
I faced same issue in eclipse neon simple maven java project
But I add below details inside pom.xml file
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
After right click on project > maven > update project (checked force update)
Its resolve me to display error on project
Hope it's will helpful
Thansk
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<fork>true</fork>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>

Compilation error when executing through pom.xml

I have a maven project and when I try to execute through pom.xml file, getting the compilation error as follows
C:testscripts/TC_Maintenance.java:[137,48] "strings in switch are not supported in -source 1.6
(use -source 7 or higher to enable strings in switch)"
I have configured jdk 1.8 in maven, could you please resolve this issue.
We have parent pom as well that is called in the pom.xml file
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
Please validate compiler option in pom.xml file also validate your maven is using correct java version using mvn -version.
<project>
[...]
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
[...]
</project>
more details about in set-compiler-source-and-target
Please make sure that you have added this plugin to your pom.xml. This will ensure that the build task uses version 1.7. We often miss this.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
Instead of including it as a plug-in, I added the section under properties above Dependencies:
<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>
I should add that this is what I believe has already been offered, but I think you added the code in the wrong area of your pom.xml, at least based upon your commented reply (it's hard to read as a comment - no formatting)
By default Maven project takes jre file try to change it to JDK JRE and check whether you are able to resolve this issue.

Create tomcat - maven project with eclipse in ubuntu

I'm tring to create a webapp with maven on, I followed this guide: http://www.youtube.com/watch?v=YeC7XQho-O0
When I create the project it say this warning:
There are no JREs installed in the workspace that are strictly compatible with this environment. testM6 Build path JRE System Library Problem
My .pom file is
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>ac.web.test</groupId>
<artifactId>testM6</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>testM6</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.4</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>jsp-api</artifactId>
<version>2.1</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>
<configuration>
<source>1.4</source>
<target>1.4</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
when I try to switch to this build tag:
<build>
<plugins>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.0</version>
</plugin>
</plugins>
</build>
I get this warning:
Description Resource Path Location Type
Build path specifies execution environment J2SE-1.5. There are no JREs installed in the workspace that are strictly compatible with this environment.
testM6 Build path JRE System Library Problem
What I miss?
Thanks much to all
I resolved with this Warning - Build path specifies execution environment J2SE-1.4
but I did not understand why it does not automatically
Eclipse is creating your build path based on your POM file. Including the JRE system library. In your configuration of the compiler plugin you specified that your source code is Java 1.4 compliant and that you wanted it to be compiled as Java 1.4 compliant.
Eclipse warns you that it has no perfect match with a "build path warning" in your Markers view. Maven will do the same when run. If you did not configure the Eclipse run-configuration for your maven build with a JDK 1.4, then Eclipse will pick whatever JDK is available (default JRE) to run Maven and Maven warns you about the fact that it may not produce what you expected.
If you have a JDK 7 configured in Eclipse, then you need to set the following as the configuration of the compiler plugin:
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
After you have done that, the warning should go away. Both the Eclipse Marker and the warning that Maven spits out when run.
I see you have java 1.5 installed in your system and you are trying to use Tomcat 7. According to this link the minimum requirement for running Tomcat 7 is java 1.6.

How do you specify the Java compiler version in a pom.xml file?

I wrote some Maven code in Netbeans that has approximately more than 2000 lines. When I compile it on Netbeans, everything is fine, but if I want to run it on command line, I will get these errors:
generics are not supported in -source 1.3
(use -source 5 or higher to enable generics)
ArrayList<ArrayList<Integer>> list = new ArrayList<ArrayList<Integer>>();
generics are not supported in -source 1.3
(use -source 5 or higher to enable generics)
HashSet<Double> resid_List = new HashSet<Double>(Arrays.asList(resid_val));
generics are not supported in -source 1.3
(use -source 5 or higher to enable generics)
List<Integer> ind_ovlpList = new ArrayList<Integer>(Arrays.asList(ind_ovlp));
generics are not supported in -source 1.3
(use -source 5 or higher to enable generics)
public class ColumnComparator implements Comparator<double[]> {
annotations are not supported in -source 1.3
(use -source 5 or higher to enable annotations)
#Override
I tried to use Java 1.3.1, compiler errors, but I got more errors. I found from other posts that I should modify pom.xml, but I do not know how. Here is my pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.mycompany</groupId>
<artifactId>mavenmain</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>mavenmain</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>gov.nist.math</groupId>
<artifactId>jama</artifactId>
<version>1.0.2</version>
</dependency>
</dependencies>
</project>
It would be great if you can help me!
maven-compiler-plugin it's already present in plugins hierarchy dependency in pom.xml. Check in Effective POM.
For short you can use properties like this:
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
I'm using Maven 3.2.5.
<project>
[...]
<build>
[...]
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>(whatever version is current)</version>
<configuration>
<!-- or whatever version you use -->
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
[...]
</build>
[...]
</project>
See the config page for the maven compiler plugin:
http://maven.apache.org/plugins/maven-compiler-plugin/examples/set-compiler-source-and-target.html
Oh, and: don't use Java 1.3.x, current versions are Java 11 or 17.
Generally you don't want to value only the source version (javac -source 1.8 for example) but you want to value both the source and the target version (javac -source 1.8 -target 1.8 for example).
Note that from Java 9, you have a way to convey both information and in a more robust way for cross-compilation compatibility (javac -release 9).
Maven that wraps the javac command provides multiple ways to convey all these JVM standard options.
How to specify the JDK version?
Using maven-compiler-plugin or maven.compiler.source/maven.compiler.target properties to specify the source and the target are equivalent.
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
and
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
are equivalent according to the Maven documentation of the compiler plugin
since the <source> and the <target> elements in the compiler configuration use the properties maven.compiler.source and maven.compiler.target if they are defined.
source
The -source argument for the Java compiler.
Default value is: 1.6.
User property is: maven.compiler.source.
target
The -target argument for the Java compiler.
Default value is: 1.6.
User property is: maven.compiler.target.
About the default values for source and target, note that
since the 3.8.0 of the maven compiler, the default values have changed from 1.5 to 1.6.
<release> tag — new way to specify Java version in maven-compiler-plugin 3.6
You can use the release argument :
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<release>9</release>
</configuration>
</plugin>
You could also declare just the user property maven.compiler.release:
<properties>
<maven.compiler.release>9</maven.compiler.release>
</properties>
But at this time the last one will not be enough as the maven-compiler-plugin default version you use doesn't rely on a recent enough version.
The Maven release argument conveys release to the Java compiler to access the JVM standard option newly added to Java 9, JEP 247: Compile for Older Platform Versions.
Compiles against the public, supported and documented API for a
specific VM version.
This way provides a standard way to specify the same version for the source, the target and the bootstrap JVM options.
Note that specifying the bootstrap is a good practice for cross compilations and it will not hurt if you don't make cross compilations either.
Which is the best way to specify the JDK version?
Java 8 and below
Neither maven.compiler.source/maven.compiler.target properties or using the maven-compiler-plugin is better.
It changes nothing in the facts since finally the two ways rely on the same properties and the same mechanism : the maven core compiler plugin.
Well, if you don't need to specify other properties or behavior than Java versions in the compiler plugin, using this way makes more sense as this is more concise:
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
Java 9 and later
The release argument (third point) is a way to strongly consider if you want to use the same version for the source and the target.
I faced same issue in eclipse neon simple maven java project
But I add below details inside pom.xml file
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
After right click on project > maven > update project (checked force update)
Its resolve me to display error on project
Hope it's will helpful
Thansk
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<fork>true</fork>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>

Categories