File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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
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: 5823
    
    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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Specify Java Version in build.xml