Reputation: 3019
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?
Upvotes: 3
Views: 12484
Reputation: 151
If you are not using maven and facing similar issue in Intellij editor, probably worth to check Project Settings. Even if you define Proper JDK, change the "Project language level" and can configure 5 onward.
Upvotes: 0
Reputation: 919
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
Upvotes: 1
Reputation: 3379
Generics were only introduced as a feature in Java 5, so when compiling using 3, generics will not be permitted. If you want more info about generics, look here. So you need to either compile using 5 or later or stop using generics.
Upvotes: 0
Reputation: 935
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>
Upvotes: 3
Reputation: 61148
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
Upvotes: 9
Reputation: 500357
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.
Upvotes: 1
Reputation: 6045
You either need to change your settings so that you're source is set to 1.5+ or remove the generics from your code:
private final TextField customer;
Upvotes: 0