Error: diamond operator is not supported in source 1.5

I am creating an application that uses cordova ionic and angular, and to scan the barcode I use native and can integrate with javascript code. If I run a project using the Eclipse IDE, it works fine, but if I perform an ionic android launch - getting the above error - the diamond operator is not supported in source 1.5

For native, I used this link https://damianflannery.wordpress.com/2011/06/13/integrate-zxing-barcode-scanner-into-your-android-app-natively-using-eclipse/ and its performance.

Can someone help in solving this problem?

+4
source share
3 answers

Try adding the apache plugin to your Pom.xml in the Build tag, as pointed out by @Sudarshan.

<build>
  <plugins>
    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-compiler-plugin</artifactId>
      <configuration>
        <source>1.7</source>
        <target>1.7</target>
      </configuration>
    </plugin>
  </plugins>
</build>

This will solve the problem.

+6
source

You are using <>, which is not supported by the java source you are using, as it is only added in Java 1.7

Find the places in the source code where you are using <>and correctly specify the generic type that is implied.

eg. if it was:

List<String> myList = new ArrayList<>();

rewrite it as

List<String> myList = new ArrayList<String>();

Note. . Although the diamond operator is a convenient shortcut, I would recommend to always indicate full generics, as it not only adds readability, but also does not create a dependency on your source for 1.7+. (Which, as we see, can sometimes lead to problems.)

+3

** Right click on the project -> Properties -> Project Boundaries -> check Java, select 1.7

0
source

All Articles