• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Specify Java Version in build.xml

 
Harish Tam
Ranch Hand
Posts: 71
Eclipse IDE Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I want to build a jar file with 1.4 version of java, i have both 1.4 and 1.5 installed on my machine and 1.5 is the default java jre and everytime it complies it uses java 1.5 is there a way we can specify the java version of compiler in the build.xml in ant process. or is there any other way so that ant uses 1.4 for compilation.

I think we can do this using the build.properties file for ANT but have no clue of this can anybody help me in this.


Thanks
Harish
 
Martijn Verburg
author
Bartender
Posts: 3275
5
Eclipse IDE Java Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can set your JAVA_HOME in the ant script (or as you say through build.properties file) in order to pick up the JDK you want for that build
 
Peter Johnson
author
Bartender
Posts: 5852
7
Android Eclipse IDE Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For the <javac> task, set the source and target properties. Example:

 
Harish Tam
Ranch Hand
Posts: 71
Eclipse IDE Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I got it after some time.

This is what you need to specify while doing javac in ANT build file

<javac srcdir="${src.dir}" destdir="${dist.dir.classes}" executable="D:\j2sdk1.4.2_05\bin\javac" compiler="javac1.4"/>

Thanks
Harish
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic