aspose 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
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Reply 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: 3268

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: 5541

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://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Specify Java Version in build.xml
 
Similar Threads
Buildfile: build.xml does not exist! Build failed
Need some Guidance in using Java 1.6 with ANT
Specify classpath for runtime
How to specify a JRE range in jnlp file?
Java version in build file