[英]problem in ant build invalid target release
problem in ant build 蚂蚁构建中的问题
[javac] Compiling 86 source files to F:\XXX\classes
[javac] javac: invalid target release: 1.6
[javac] Usage: javac <options> <source files>
[javac] where possible options include:
[javac] -g Generate all debugging info
[javac] -g:none Generate no debugging info
[javac] -g:{lines,vars,source} Generate only some debugging info
[javac] -nowarn Generate no warnings
[javac] -verbose Output messages about what the compiler is doing
[javac] -deprecation Output source locations where deprecated APIs are used
[javac] -classpath <path> Specify where to find user class files
[javac] -cp <path> Specify where to find user class files
[javac] -sourcepath <path> Specify where to find input source files
[javac] -bootclasspath <path> Override location of bootstrap class files
[javac] -extdirs <dirs> Override location of installed extensions
[javac] -endorseddirs <dirs> Override location of endorsed standards path
[javac] -d <directory> Specify where to place generated class files
[javac] -encoding <encoding> Specify character encoding used by source files
[javac] -source <release> Provide source compatibility with specified release
[javac] -target <release> Generate class files for specific VM version
[javac] -version Version information
[javac] -help Print a synopsis of standard options
[javac] -X Print a synopsis of nonstandard options
[javac] -J<flag> Pass <flag> directly to the runtime system
BUILD FAILED
ant source and target to 1.6 en variable path to jdk 1.6 ant源和目标1.6到jdk 1.6的可变路径
You use a compiler that cannot compile with -target 1.6
(javac: invalid target release: 1.6). 您使用的编译器无法使用
-target 1.6
编译(javac:无效的目标版本:1.6)。 Are you sure you use the JDK 1.6? 你确定使用JDK 1.6吗? Maybe a JDK 1.5 is installed and used by ant.
也许安装并使用了JDK 1.5。 Check the used Java-version with adding following line to your target (at the beginning):
检查使用过的Java版本,并在目标中添加以下行(在开头):
<echo message="Using Java version ${ant.java.version}."/>
It outputs the Java-version used by Ant. 它输出Ant使用的Java版本。
You can set the compiler to use a different Java-version. 您可以将编译器设置为使用其他Java版本。 You have to use the fork-attribute to use an external javac and specify which one you want:
您必须使用fork-attribute来使用外部javac并指定您想要的那个:
<javac srcdir="${src}"
destdir="${build}"
fork="yes"
executable="/opt/java/jdk1.6/bin/javac"
/>
Read the documentation of the javac-task for details. 有关详细信息,请阅读javac-task的文档。
此外,您可以在Ant视图中右键单击项目,然后选择Run As ...> External Tools Configuration ...在JRE选项卡中,选择正确的Runtime JRE。
Maybe need to make the ant builder match your jre. 也许需要让蚂蚁生成器匹配你的jre。
At Windows->Preferences->Ant->Runtime->Classpath->Global Entries
, add <*your jre home*>/lib/tools.jar
and move it up. 在
Windows->Preferences->Ant->Runtime->Classpath->Global Entries
,添加<*your jre home*>/lib/tools.jar
并将其移动。
Yes, this is an old one, but came across at work and could not find a solution documented anywhere yet... 是的,这是一个旧的,但在工作中遇到,无法在任何地方找到解决方案......
Even though I too came across this using Ant, it in fact does not seem to have anything to do with Ant - there seem to have been some broken JDK builds out there: 虽然我也使用Ant来实现这一点,但事实上它似乎与Ant没有任何关系 - 似乎有一些破坏的JDK构建:
C:\>%JAVA_HOME%\bin\javac -version
javac 1.6.0_21
javac: no source files
Usage: javac <options> <source files>
...
C:\>%JAVA_HOME%\bin\javac -target 1.6
javac: invalid target release: 1.6
Usage: javac <options> <source files>
...
Where as another 1.6 build looks like: 另外1.6版本看起来像:
C:\>set JAVA_HOME=C:\Progra~1\Java\jdk1.6.0_45
C:\>%JAVA_HOME%\bin\javac -version
javac 1.6.0_45
C:\>%JAVA_HOME%\bin\javac -target 1.6
javac: no source files
Usage: javac <options> <source files>
use -help for a list of possible options
So the solution is to upgrade JDK. 所以解决方案是升级JDK。
Right click on ant build file; 右键单击ant build文件; Run As;
跑步; Ant Build...;
Ant Build ......; JRE tab;
JRE标签; and try setting a separate JRE to the one you want.
并尝试将单独的JRE设置为您想要的JRE。 That worked for me, even though I only have one JRE installed, Eclipse seemed to be remembering the ghost of an old one.
这对我有用,即使我只安装了一个JRE,Eclipse似乎还记得旧版的幽灵。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.