aspose file tools*
The moose likes Ant, Maven and Other Build Tools and the fly likes Java Compiler version Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "Java Compiler version" Watch "Java Compiler version" New topic
Author

Java Compiler version

Payam Fard
Ranch Hand

Joined: Jan 31, 2003
Posts: 73
Hi all,
If I have multiple versions of JDK installed on my machine, how using ANT would I specify which version to use for compilation?
Thanks,
Payam.
Theodore Casser
Ranch Hand

Joined: Mar 14, 2001
Posts: 1902

You can apparently specify an environmental variable to tell it which JVM to use:
JAVACMD - full path of the Java executable. Use this to invoke a different JVM than JAVA_HOME/bin/java(.exe).
But as for on the fly, that I can't find information on...


Theodore Jonathan Casser
SCJP/SCSNI/SCBCD/SCWCD/SCDJWS/SCMAD/SCEA/MCTS/MCPD... and so many more letters than you can shake a stick at!
Matthew Phillips
Ranch Hand

Joined: Mar 09, 2001
Posts: 2676
There are two targets involved with the javac tag that you may use to change this. You need to set the fork tag to yes and the executable tag needs to to be set to the path of the javac executable that you with to use.


Matthew Phillips
Felicia K Lei
Greenhorn

Joined: Jul 19, 2005
Posts: 7
How can I know the version of javac executed in the build.xml by ANT. Because I am suspecting the javac version used by ant/build.xml is not the default version under my unix prompt.

To make things clear, how can I write something like "java -version" or "which javac" in build.xml so that I can tell the version by the output?

Any help is appreciated.
Tim West
Ranch Hand

Joined: Mar 15, 2004
Posts: 539
You probably want:




-Tim
Felicia K Lei
Greenhorn

Joined: Jul 19, 2005
Posts: 7
Tim, Yes, Thanks a lot.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Java Compiler version