Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Java Compiler version

 
Payam Fard
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1902
Hibernate Netbeans IDE PHP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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...
 
Matthew Phillips
Ranch Hand
Posts: 2676
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Felicia K Lei
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 539
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You probably want:




-Tim
 
Felicia K Lei
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tim, Yes, Thanks a lot.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic