I have a problem while maven packaging. In this code:
public class LoginDialog extends Dialog {
private final TextField customer;
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.
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
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.
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
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>
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.