Ant is using wrong java version

前端 未结 16 1388
小蘑菇
小蘑菇 2020-11-28 09:20

I\'m using Ant 1.7.0 and installed java 1.6 which is in JAVA_HOME.

I want to build a project using java 1.5, so I\'ve exported JAVA_HOME to be my java 1.5 directory.

相关标签:
16条回答
  • 2020-11-28 10:21

    You could achieve that with following steps, if you are using Eclipse IDE:

    1. Right click on the task in your ant build file (build.xml).

    2. Mouse over "Run As", click on "External Tool Configurations...".

    3. Add followings to "Arguments":

      -Dant.build.javac.target=1.5 -Dant.build.javac.source=1.5
      
    0 讨论(0)
  • 2020-11-28 10:21

    You can also specify in a javac task what level of compatibility ( 1.4, 1.5, 1.6 ) you want to use, you can set the "source" and "target" level values, check the docs here : Javac task documentation

    0 讨论(0)
  • 2020-11-28 10:23

    If you are not using eclipse. Then you can change the ant java property directly on the file as mentioned here.

    http://pissedoff-techie.blogspot.in/2014/09/ant-picks-up-incorrect-java-version.html

    0 讨论(0)
  • 2020-11-28 10:23

    If you run Ant from eclipse, the eclipse will use jdk or jre that is configured in the class-path(build path).

    0 讨论(0)
提交回复
热议问题