wood burning stoves*
The moose likes Ant, Maven and Other Build Tools and the fly likes Specify Java Version in build.xml Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "Specify Java Version in build.xml " Watch "Specify Java Version in build.xml " New topic
Author

Specify Java Version in build.xml

Harish Tam
Ranch Hand

Joined: Feb 17, 2005
Posts: 71

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


SCJP 1.4, SCWCD 1.4
Martijn Verburg
author
Bartender

Joined: Jun 24, 2003
Posts: 3274
    
    5

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


Cheers, Martijn - Blog,
Twitter, PCGen, Ikasan, My The Well-Grounded Java Developer book!,
My start-up.
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5812
    
    7

For the <javac> task, set the source and target properties. Example:



JBoss In Action
Harish Tam
Ranch Hand

Joined: Feb 17, 2005
Posts: 71

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
 
jQuery in Action, 2nd edition
 
subject: Specify Java Version in build.xml
 
Similar Threads
How to specify a JRE range in jnlp file?
Need some Guidance in using Java 1.6 with ANT
Buildfile: build.xml does not exist! Build failed
Specify classpath for runtime
Java version in build file