0

I am developing a java project and every thing working fine, then once I needed to change the version of a library I use. When I run mvn install a compilation error appeared:

[ERROR] COMPILATION ERROR : [INFO] ------------------------------------------------------------- [ERROR] /C:/Users/marwa/eclipse-workspace-photon/OntologyReuseProject/src/main/java/OntologyMatchingPackage/AMLMappings.java:[94,61] diamond operator is not supported in -source 1.5 (use -source 7 or higher to enable diamond operator) [ERROR] /C:/Users/marwa/eclipse-workspace-photon/OntologyReuseProject/src/main/java/OntologyMatchingPackage/OntologyMatchingAlgorithm.java:[42,60] diamond operator is not supported in -source 1.5 (use -source 7 or higher to enable diamond operator) [INFO] 2 errors

I am using Java 1.7 and also after this error I try to use 1.8 but the error still appear although the project is running correctly . How to solve this compilation error?

Jonny Henly
  • 4,023
  • 4
  • 26
  • 43
  • Add the relevant pom please. – LMC Sep 01 '21 at 00:04
  • Does this answer your question? [Specifying java version in maven - differences between properties and compiler plugin](https://stackoverflow.com/questions/38882080/specifying-java-version-in-maven-differences-between-properties-and-compiler-p) – dan1st Sep 04 '21 at 19:55

1 Answers1

0

This error is most likely caused by a wrong or missing source version in the maven-compiler-plugin configuration in your project's pom.xml file. You should set the source property to at least 1.7, as the diamond operator was introduced in Java 7. Example configuration:

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.7.0</version>
                <configuration>
                    <showDeprecation>true</showDeprecation>
                    <source>1.7</source>
                    <target>1.7</target>
                </configuration>
            </plugin>
Pieter12345
  • 1,713
  • 1
  • 11
  • 18
  • But still give me errors although the project runs normaly from eclipse The errors are: [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.7.0:compile (default-compile) on project OntologyReuseProject: Compilation failure: Compilation failure: [ERROR] /C:/eclipse-workspace-photon/OntologyReuseProject/src/main/java/OntologyMatchingPackage/AMLMappings.java:[8,11] package aml does not exist [ERROR] /C:/eclipse-workspace-photon/OntologyReuseProject/src/main/java/AgentClasses/ConceptUtilityClass.java:[8,38] package org.coode.owlapi.rdfxml.parser does not exist – marwa hussein Sep 01 '21 at 01:49
  • seems as it can not see some packages although they exist and nothing changed! – marwa hussein Sep 01 '21 at 01:55
  • Solved. I had a java version mismatch ,so I have corrected it and i am able to build successfully. – marwa hussein Sep 01 '21 at 02:12