When i try to compile(running maven install) in the eclipse,i am getting an error of not compatibility.It seems that,for some reason,maven uses old jre/jdk and doesn't use the one specified in the Path env. variable.Even though when i run mvn -v,it outputs that maven uses the correct version(on my local machine)
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /C:/Users/Barracuda/Desktop/Projects/Eclipse Projects/PetClinicWeb/src/main/java/com/model/databasePackage/implementations/DBConnection.java:[132,21] try-with-resources is not supported in -source 1.5
(use -source 7 or higher to enable try-with-resources)
[ERROR] /C:/Users/Barracuda/Desktop/Projects/Eclipse Projects/PetClinicWeb/src/main/java/com/model/databasePackage/implementations/DBConnection.java:[223,50] diamond operator is not supported in -source 1.5
(use -source 7 or higher to enable diamond operator)
[ERROR] /C:/Users/Barracuda/Desktop/Projects/Eclipse Projects/PetClinicWeb/src/main/java/com/model/adv/DBConnection.java:[64,38] diamond operator is not supported in -source 1.5
(use -source 7 or higher to enable diamond operator)
[ERROR] /C:/Users/Barracuda/Desktop/Projects/Eclipse Projects/PetClinicWeb/src/main/java/com/model/adv/DBConnection.java:[80,21] try-with-resources is not supported in -source 1.5
(use -source 7 or higher to enable try-with-resources)
[ERROR] /C:/Users/Barracuda/Desktop/Projects/Eclipse Projects/PetClinicWeb/src/main/java/com/model/databasePackage/implementations/ObjectComparators.java:[21,48] diamond operator is not supported in -source 1.5
(use -source 7 or higher to enable diamond operator)
[ERROR] /C:/Users/Barracuda/Desktop/Projects/Eclipse Projects/PetClinicWeb/src/main/java/com/model/adv/ObjectComparators.java:[21,48] diamond operator is not supported in -source 1.5
(use -source 7 or higher to enable diamond operator)
[ERROR] /C:/Users/Barracuda/Desktop/Projects/Eclipse Projects/PetClinicWeb/src/main/java/com/model/adv/DatabaseTable.java:[420,51] diamond operator is not supported in -source 1.5
(use -source 7 or higher to enable diamond operator)
[INFO] 7 errors
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.142 s
[INFO] Finished at: 2019-04-14T09:44:36+03:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project PetClinic: Compilation failure: Compilation failure:
[ERROR] /C:/Users/Barracuda/Desktop/Projects/Eclipse Projects/PetClinicWeb/src/main/java/com/model/databasePackage/implementations/DBConnection.java:[132,21] try-with-resources is not supported in -source 1.5
[ERROR] (use -source 7 or higher to enable try-with-resources)
[ERROR] /C:/Users/Barracuda/Desktop/Projects/Eclipse Projects/PetClinicWeb/src/main/java/com/model/databasePackage/implementations/DBConnection.java:[223,50] diamond operator is not supported in -source 1.5
[ERROR] (use -source 7 or higher to enable diamond operator)
[ERROR] /C:/Users/Barracuda/Desktop/Projects/Eclipse Projects/PetClinicWeb/src/main/java/com/model/adv/DBConnection.java:[64,38] diamond operator is not supported in -source 1.5
[ERROR] (use -source 7 or higher to enable diamond operator)
[ERROR] /C:/Users/Barracuda/Desktop/Projects/Eclipse Projects/PetClinicWeb/src/main/java/com/model/adv/DBConnection.java:[80,21] try-with-resources is not supported in -source 1.5
[ERROR] (use -source 7 or higher to enable try-with-resources)
[ERROR] /C:/Users/Barracuda/Desktop/Projects/Eclipse Projects/PetClinicWeb/src/main/java/com/model/databasePackage/implementations/ObjectComparators.java:[21,48] diamond operator is not supported in -source 1.5
[ERROR] (use -source 7 or higher to enable diamond operator)
[ERROR] /C:/Users/Barracuda/Desktop/Projects/Eclipse Projects/PetClinicWeb/src/main/java/com/model/adv/ObjectComparators.java:[21,48] diamond operator is not supported in -source 1.5
[ERROR] (use -source 7 or higher to enable diamond operator)
[ERROR] /C:/Users/Barracuda/Desktop/Projects/Eclipse Projects/PetClinicWeb/src/main/java/com/model/adv/DatabaseTable.java:[420,51] diamond operator is not supported in -source 1.5
[ERROR] (use -source 7 or higher to enable diamond operator)
[ERROR] -> [Help 1]
[ERROR]
How should i fix this?And can i do it without specifying each time in the POM.xml which version to use,but to tell maven to use the Path env. var. ? Here is what is specified in the eclipse:
This is the JAVA_HOME env. var.
This is the MAVEN_HOMEenv. var.
Here — the outputs of mvn -v and java -version
And 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.arslan</groupId>
<artifactId>PetClinic</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>Pet Clinic Web Application</name>
<dependencies>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>4.0.1</version>
<scope>provided</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/junit/junit -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
Even running mvn install from command line doesn't help.