Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I use maven test to run my project but it said I was using JDK 1.3 [duplicate]

Tags:

java

maven

Possible Duplicate:
Maven Install: “Annotations are not supported in -source 1.3”

I use ubuntu 10.04 and open-jdk-1.6.0.

This is my mvn -version output:

Apache Maven 2.2.1 (rdebian-1)
Java version: 1.6.0_20
Java home: /usr/lib/jvm/java-6-openjdk/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux" version: "2.6.32-37-generic" arch: "i386" Family: "unix"

But when I run mvn test, there are some errors:

/home/unionx/workspace/java/try-netty/src/test/java/net/bluedash/trynetty/DataTypeTest.java:[3,7] static import declarations are not supported in -source 1.3
(use -source 5 or higher to enable static import declarations)
import static org.junit.Assert.assertEquals;

/home/unionx/workspace/java/try-netty/src/test/java/net/bluedash/trynetty/DataTypeTest.java:[11,2] annotations are not supported in -source 1.3
(use -source 5 or higher to enable annotations)
@Test

/home/unionx/workspace/java/try-netty/src/test/java/net/bluedash/trynetty/ChannelBufferTest.java:[3,7] static import declarations are not supported in -source 1.3
(use -source 5 or higher to enable static import declarations)
import static org.junit.Assert.*;

/home/unionx/workspace/java/try-netty/src/test/java/net/bluedash/trynetty/ChannelBufferTest.java:[11,2] annotations are not supported in -source 1.3
(use -source 5 or higher to enable annotations)
@Test

/home/unionx/workspace/java/try-netty/src/test/java/net/bluedash/trynetty/PathTest.java:[3,7] static import declarations are not supported in -source 1.3
(use -source 5 or higher to enable static import declarations)
import static org.junit.Assert.*;

/home/unionx/workspace/java/try-netty/src/test/java/net/bluedash/trynetty/PathTest.java:[11,2] annotations are not supported in -source 1.3
(use -source 5 or higher to enable annotations)
@Test

I seems that the mvn thought I use java 1.3, perhaps it just support java 1.5?

like image 913
unionx Avatar asked Nov 26 '25 11:11

unionx


1 Answers

http://maven.apache.org/general.html#Compiling-J2SE-5

How do I set up Maven so it will compile with a target and source JVM of my choice? You must configure the source and target parameters in your pom. For example, to set the source and target JVM to 1.5, you should have in your pom:

...
<build>
...
  <plugins>
    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-compiler-plugin</artifactId>
      <version>2.3.2</version>
       <configuration>
        <source>1.5</source>
        <target>1.5</target>
       </configuration>
    </plugin>
  </plugins>
...
</build>
...
like image 124
Chris Nava Avatar answered Nov 28 '25 01:11

Chris Nava



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!