English 中文(简体)
Compiling Java 7 via
原标题:Compiling Java 7 code via Maven
  • 时间:2012-12-26 16:05:26
  •  标签:
  • java
  • maven

My pom file list

<project>
  <build>
    <pluginManagement>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.0</version>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.12.4</version>
            </plugin>
        </plugins>
    </pluginManagement>
    <plugins>
        <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <configuration>
                <source>1.7</source>
                <target>1.7</target>
            </configuration>
        </plugin>
    </plugins>
  ...

但是,在<条码>上,我收到了<<>tmvn Cleanstal>。

[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR : 
[INFO] -------------------------------------------------------------
[ERROR] Failure executing javac, but could not parse the error:
javac: invalid target release: 1.7
Usage: javac <options> <source files>

java version "1.7.0_10"
Java(TM) SE Runtime Environment (build 1.7.0_10-b18)
Java HotSpot(TM) 64-Bit Server VM (build 23.6-b04, mixed mode)

。 还提到了正确的 Java版。

/usr/bin/javac -> /Library/Java/JavaVirtualMachines/jdk1.7.0_10.jdk/Contents/Home/bin/javac

On this machine, I am using zsh (echo $0 returns -zsh)

在我的<代码>zshrc上, 我已界定:

 33 # HOME
 34 JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.7.0_10.jdk/Contents/Home
 35 SCALA_HOME=/Library/Scala/current
 36 FORGE_HOME=~/tools/forge/
 37 
 38 # PATH
 39 PATH="/Library/Frameworks/Python.framework/Versions/3.2/bin:${PATH}"
 40 PATH=${PATH}:${JAVA_HOME}/bin
 41 PATH=${PATH}:/bin/
 42 PATH=${PATH}:/sbin/
 43 PATH=${PATH}:/usr/bin/
 44 PATH=${PATH}:/usr/sbin/
 45 PATH=${PATH}:/opt/local/bin/
 46 PATH=${PATH}:/opt/local/sbin/
 47 PATH=${PATH}:/usr/local/git/bin
 48 PATH=${PATH}:/usr/local/git/sbin
 49 PATH=${PATH}:/Applications/Xcode.app/Contents/Developer/usr/bin
 50 PATH=${PATH}:${SCALA_HOME}/bin
 51 PATH=${PATH}:${FORGE_HOME}/bin
 52 
 53 export PATH

当我正在运行<条码>。 我认为,事实上我使用 Java 6

  1 Apache Maven 3.0.3 (r1075438; 2011-02-28 11:31:09-0600)
  2 Maven home: /usr/share/maven
  3 Java version: 1.6.0_35, vendor: Apple Inc.
  4 Java home: /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home

如何界定? 我有过多次发源。

最佳回答

检查<代码>mvn,在您的装配中注明,看看它如何建造指挥系统。 也许你或其他人在那里很难编码,并忘记了这一条。

问题回答

尝试使用更新版本的马文汇编者金:

    <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.2</version>
        <configuration>
            <source>1.7</source>
            <target>1.7</target>
        </configuration>
    </plugin>

在全球范围,更妥善地确定母鱼的源档案:

<properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

www.un.org/Depts/DGACM/index_spanish.htm 由于这一答案仍在引起注意,只是要指出,最新数值(如最近的编辑)为:ma子的3.2和 j的1.8,因为关于通过ven子编纂java 8代码的问题必须很快出现:-

我也存在同样的问题,并且按照这一博客条款解决了这一问题:

$ vim .bash_profile 

export JAVA_HOME=$(/usr/libexec/java_home)

$ source .bash_profile

$ echo $JAVA_HOME
/Library/Java/JavaVirtualMachines/1.7.0.jdk/Contents/Home

Special tks to

请查看以下标签的 you。

<properties>
    <maven.compiler.source>1.7</maven.compiler.source>
    <maven.compiler.target>1.7</maven.compiler.target>
</properties>

它应当指出必要的jdk版本。

你必须检查Maven版本:

mvn -version

你们将发现Maven用于汇编的 Java版。 您可能需要重新设立JAVA_ HOME(如果需要的话)。

我有同样的问题。 我发现,这是因为Maven的文字审视了目前JDK的链接,找到了1.6个JDK。 即便是你安装了最新的JDK,这还是没有解决的。 虽然你只是将JAVA_HOME列入你的地址,但还是可以把大话写在上面。 我选择确定象征性联系如下:

ls -l /System/Library/Frameworks/JavaVM.framework/Versions/
total 64
lrwxr-xr-x  1 root  wheel   10 30 Oct 16:18 1.4 -> CurrentJDK
lrwxr-xr-x  1 root  wheel   10 30 Oct 16:18 1.4.2 -> CurrentJDK
lrwxr-xr-x  1 root  wheel   10 30 Oct 16:18 1.5 -> CurrentJDK
lrwxr-xr-x  1 root  wheel   10 30 Oct 16:18 1.5.0 -> CurrentJDK
lrwxr-xr-x  1 root  wheel   10 30 Oct 16:18 1.6 -> CurrentJDK
lrwxr-xr-x  1 root  wheel   10 30 Oct 16:18 1.6.0 -> CurrentJDK
drwxr-xr-x  9 root  wheel  306 11 Nov 21:20 A
lrwxr-xr-x  1 root  wheel    1 30 Oct 16:18 Current -> A
lrwxr-xr-x  1 root  wheel   59 30 Oct 16:18 CurrentJDK -> /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents

1. 现JDK在1.6.0.jdk点发出通知

为了安定它,我有以下指挥(你应检查你安装的版本,并相应作出调整)。

sudo rm /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK
sudo ln -s /Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/ /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK

您可以尝试一个更新颖的花 the;在玉米现场:

<version>3.0</version>

我也看到:

<compilerVersion>1.7</compilerVersion>

改变Eclipse-Ec房地产的 Java编环境

Goto: Preferences->Java->Compiler->Compiler Compliance Level-> 1.7 Apply Ok

重新启动民主选举学会。

Confirm Compiler setting for project- Goto: Project Properties->Java Compiler-> Uncheck(Use Compliance from execution environment JavaSE-1.6 on the java Build path.) and select 1.7 from the dropdown. (Ignore if already 1.7)

重新启动民主选举学会。

如果仍然存在问题,则采用终端站式指挥进行个人检测的案件

mvn -Dtest=<test class name> test

不能确定本处使用什么,但你可以消除许多单./乌邦图的java版本,并更新java-alternatives,使缺水系统宽广。

#> update-java-alternatives -l
java-1.6.0-openjdk-amd64 1061 /usr/lib/jvm/java-1.6.0-openjdk-amd64
java-1.7.0-openjdk-amd64 1071 /usr/lib/jvm/java-1.7.0-openjdk-amd64
java-6-sun 63 /usr/lib/jvm/java-6-sun
java-7-oracle 1073 /usr/lib/jvm/java-7-oracle

1. 设定一个新的用途:

#> update-java-alternatives -s java-7-oracle

No need to set JAVA_HOME for most apps.

right click on ur project in eclipse and open "Run Configurations"..check the jre version there. some times this will not change by default in eclipse,after even changing the version in the buildpath.

具体汇编需要a(无标识<代码>/etc/alternatives/java) JVM, consider prefixing the mvn 指令JAVA_HOME 同样,

JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64/ mvn package

这里,我们假设的是 Java8,而就手头的具体项目而言,我们要求 Java7。

{JAVA_1_4_HOME}/bin/javacyou也能尝试......

        <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <configuration>
                    <source>1.7</source>
                    <target>1.7</target>
                    <showDeprecation>true</showDeprecation>
                    <showWarnings>true</showWarnings>
                    <executable>{JAVA_HOME_1_7}/bin/javac</executable>
                    <fork>true</fork>
            </configuration>
        </plugin>

奥基先生,我自己也解决了这一问题。 如果与Maven plugin的原始来源/目标特性相比,你没有低版或低版,你会发现这一错误。

肯定在您的JAVA_中有一个好版本。 HOME, and have included in the PATH.

以前的任何答复都没有完全解决我的使用问题。

需要拆除正在修建的目录。 清洁。 接着又重新开始。 看像沉默许可问题。

我在IntelliJ IDEA 14号案中曾提到过这个问题,直到我进入档案馆——和; 项目结构,将项目SDK改为1.7,项目语言水平提高到7。

我在玩ec时曾有过这个问题,我不得不改变该项目的修建道路,以便它提及7岁。

You might be specifying a wrong version of java. java -version(in your terminal) to check the version of java you are using. Go to [maven-compile-plugin][1] for the latest maven compiler version [1]: http://maven.apache.org/plugins/maven-compiler-plugin/ Your plugin may appear like this if you are using java 6 and the latest version of maven compiler plugin is 3.1

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




相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...