-1

For compilation of my Java code, I would like to know if its possible to use one version of the JRE(rt.jar) and use javac belonging to another version of JDK. If yes, how do we include it in the build.xml in Ant? Thanks in advance!

Müller
  • 973
  • 6
  • 19
  • 38
  • 1
    Possible duplicate of [How to change Ant compiler to JDK 1.6](http://stackoverflow.com/questions/11551678/how-to-change-ant-compiler-to-jdk-1-6) – Chad Nouis May 10 '16 at 14:18
  • I know how to change the Ant compiler to a different version. My question is whether it is possible for ant to pick up different JRE and JDK when doing the build. Essentially, if it is possible to have some parameters passing different JRE/JDK values to the build. – Müller May 11 '16 at 05:26

1 Answers1

0

Yes, you can. You use the executable attribute to specify the exact location of javac you want to use, so you can point to another JDK. And you need to set the fork attribute to yes.

<javac fork="yes" executable="...path.../jdk/bin/javac">
Roberg
  • 1,083
  • 1
  • 12
  • 11