generics are not supported in -source 1.3

12,125

Solution 1

Generics were added in java 1.5. Your maven is compiling for java 1.3.

This can be fixed in one of two ways.

Remove generics so that you can compile for < 1.5

Change the maven configuration to compile for a newer version of java. You should be able to edit your compiler plugin in your pom:

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.0</version>
            <configuration>
                <source>1.5</source>
                <target>1.5</target>
            </configuration>
        </plugin>

This tells maven to compile for 1.5

Solution 2

You need to tell the maven compiler plugin that your code is using a recent java version. For instance, if you are using java 7, to the following:

<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>

Solution 3

Android studio: It fixes by adding these below lines in the file app build.gradle

compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 }

Note: use the latest java version, here I'm using java 8

Solution 4

When you compile your code with -source 1.3, the compiler does not support assertions, generics, or other language features introduced after JDK 1.3.

Share:
12,125
Nikitin Mikhail
Author by

Nikitin Mikhail

Updated on June 27, 2022

Comments

  • Nikitin Mikhail
    Nikitin Mikhail almost 2 years

    I have a problem while maven packaging. In this code:

    public class LoginDialog extends Dialog {
    
        private final TextField<String> customer;
                              ^here
        private final TextField<String> login1;
        private final TextField<String> password1;
        private final MainController controller= new MainController();
        private String customerId;
        private String login;
        private String password;
    

    I have an error like:

    [ERROR] BUILD FAILURE
    [INFO] ------------------------------------------------------------------------
    [INFO] Compilation failure
    ...src/main/java/com/messagedna/web/client/widget/LoginDialog.java:[19,27] error: generics are not supported in -source 1.3
    

    what may be the reason of this?