4

I have build.xml which calls swfbuild.xml. I want parent build.xml to use IBM JDK 1.5 and swfbuild.xml to use Sun JDK 1.6

Is there any option in <ant> task to specify different JDK to use?

I tried setting JAVACMD like below but that doesn't work either

How can I use different JDK for swfbuild.xml?

    <target name="Compile_SWF">
        <exec executable="cmd">
            <env key="JAVACMD" value="C:/Program Files/Java/jdk1.6.0_18" />
        </exec>
        <echo message="Start to Compile SWF content" />
        <ant antfile="swfbuild.xml" target="swf-masterbuild" />
        <exec executable="cmd">
            <env key="JAVACMD" value="C:/IBM/SDP/runtimes/base_v61/java" />
        </exec>
    </target>
Vineet Bhatia
  • 2,469
  • 4
  • 30
  • 28
  • Why do you need to use a different JDK on swfbuild.xml? Is it for the javac compiler, or do you need to run a custom task that requires 1.6 support? – Tap Jul 11 '13 at 13:33
  • swfbuild.xml has mxmlc task for which I want to use Sun JDK 1.6 because of some compatibility issues with mxmlc (flex compiler) – Vineet Bhatia Jul 11 '13 at 13:36

1 Answers1

6

In each xml file, you can specify the executable to use inside the javac task. You must include the fork=yes in addition to the executable= parameter.

<javac fork="yes" executable="C:/Program Files/Java/jdk1.7.0_17/bin/javac">
  • In swfbuild.xml I have mxmlc task not javac – Vineet Bhatia Jul 11 '13 at 13:48
  • Ok. Have you tried setting JAVA_HOME instead of JAVACMD using the method you specified in your question? From what I can tell the mxmlc compiler looks for that environment variable to determine which JDK to use. See http://help.adobe.com/en_US/flex/using/WS2db454920e96a9e51e63e3d11c0bf69084-7fd9.html – Dave Bartlett Jul 11 '13 at 13:55
  • The "" task is not taking JAVACMD or JAVA_HOME. How should I set the JAVA_HOME env? – Vineet Bhatia Jul 11 '13 at 14:44
  • 2
    It seems this might not be possible. Although there seem to be ways to set environment variables from Ant (using the exec with cmd for windows) none of them seem to work in the currently executing ant task. I guess one solution is instead of using the 'ant' task to start the swfbuild.xml, you exec a script that sets the JAVA_HOME then calls ant on that xml file. – Dave Bartlett Jul 11 '13 at 15:51