蚂蚁错误:不支持菱形运算符

时间:2016-06-10 11:28:19

标签: java ant

我正在尝试构建JLaTeXMath-android,可以找到here。但是,当我运行ant时,我得到了

D:\android studio\jlatexmath-android-master>ant
Buildfile: D:\android studio\jlatexmath-android-master\build.xml

init:

compile:
    [javac] Compiling 147 source files to D:\android studio\jlatexmath-android-m
aster\bin
    [javac] warning: [options] bootstrap class path not set in conjunction with
-source 1.5
    [javac] D:\android studio\jlatexmath-android-master\src\org\scilab\forge\jla
texmath\ArrayOfAtoms.java:40: error: diamond operator is not supported in -sourc
e 1.5
    [javac]     array = new LinkedList<>();
    [javac]                            ^
    [javac]   (use -source 7 or higher to enable diamond operator)
    [javac] D:\android studio\jlatexmath-android-master\src\org\scilab\forge\jla
texmath\Box.java:106: error: diamond operator is not supported in -source 1.5
    [javac]     protected LinkedList<Box> children = new LinkedList<>();
    [javac]                                                         ^
    [javac]   (use -source 7 or higher to enable diamond operator)
    [javac] 2 errors
    [javac] 1 warning

BUILD FAILED
D:\android studio\jlatexmath-android-master\build.xml:88: Compile failed; see th
e compiler error output for details.

Total time: 0 seconds

我也试过ant -Djava.source=7 -Djava.target=7同样的结果。任何想法?

编辑:在阅读完第一个建议之后,我尝试了-antDjava_verion=1.7,因为这是一直放入源和目标的值。输出超出了字符的限制,所以我上传了它:http://www.file-upload.net/download-11663609/out.txt.html

1 个答案:

答案 0 :(得分:1)

在build.xml中的source任务中指定targetjavac属性:

<javac source="1.7"
       target="1.7"
       ... other attributes

如果您使用的是Java 8,请使用1.7或1.8。