简体   繁体   中英

Why does mvn 3.0.4 use -source 1.3 on Ubuntu 13.04 when I have Oracle JDK 1.7 installed?

I have mvn 3.0.4 and Oracle JDK 1.7 installed on Ubuntu 13.04. When I build an existing project I get

error: generics are not supported in -source 1.3

This same project works on Windows 7 with JDK 1.7 and mvn 3.0.4 without modifying the pom.xml to tell it which version of Java to use.

Ubuntu has openjdk 1.7 installed, but I have Oracle JDK 1.7 in the path before openjdk.

What's wrong with maven on Ubuntu 13.04?

Thanks.

You need to tell Maven to use JDK 1.5(???) to compile your source code explicitly. Declare Maven compiler plugin (maven-compiler-plugin) in your pom.xml file, like this :

File : pom.xml

<project ...>
<dependencies>
...
</dependencies>
<build>
<plugins>
   <plugin>
       <groupId>org.apache.maven.plugins</groupId>
       <artifactId>maven-compiler-plugin</artifactId>
       <version>2.3.1</version>
       <configuration>
           <source>1.5</source>
           <target>1.5</target>
       </configuration>
   </plugin>
  </plugins>
</build>

I removed mvn 3.0.4 (Ubuntu packaged version) and installed 3.1.0 (from Apache web site) and it now works. There must be a problem with the packaged version of mvn 3.0.4 for Ubuntu.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM