CodeRocker
CodeRocker

Reputation: 67

How to set java_home in ant build xml

I need to run my project on java 1.4 and
pmd and findbugs on java 1.5
So, i need to set java_home in my build xml.

Thanks in advance,
-Sravan

Upvotes: 4

Views: 13370

Answers (2)

RicoZ
RicoZ

Reputation: 845

There is a attribute called "jvm" for the java-task:

<java jvm="PATH_TO_YOUR_VM" fork="true"...>
...
</java>

Upvotes: 4

mstrok
mstrok

Reputation: 21

Alternatively, if you are in Windows, you could create 2 batch files: one that sets JAVA_HOME to 1.3 followed by your call to ant, a second one that sets JAVA_HOME to 1.4 followed by your call to ant. ex:

startAnt1.3.bat:

SET JAVA_HOME=C:\Java1.3\etc.
ant myTarget

startAnd1.4.bat:

SET JAVA_HOME=C:\Java1.4\etc.
ant myTarget

Upvotes: 0

Related Questions