• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem with ANT using a different JDK version

 
Amir Pourteymour
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Does anybody know if ANT by default uses a different version of JDK than the one JAVA_HOME is pointing to?

Cause when I print out my jdk versions, I get a older version comparing to when I run the class separately outside of ant.


Thanks
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you have JAVA_HOME defined it should use that. If you don't it will try to work out where JAVA_HOME is (assuming you are using the batch or shell scripts to run it).

Some Ant tasks can specify a different JVM depending on what they do. Check the docs.
 
Amir Pourteymour
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you think if I add a JAVA_HOME property in my ant, it starts using this instead of whatever it has?



thanks,
 
Rob Spoor
Sheriff
Pie
Posts: 20514
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not sure, but I doubt it. AFAIK the JAVA_HOME variable is used when starting Ant, which is a Java program. I don't see it changing its own JVM just like that.
 
Amir Pourteymour
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
if I compile my class like this =>
javac -source 1.3 -target 1.4 JVMVersion.java

it works very well and gives me JDK versions it is using:
Java Version : 1.6.0_03
Java vendor : Sun Microsystems Inc.
Java home : C:\Program Files\Java\jre1.6.0_03
*************
JVM specification version : 1.0
JVM Version : 1.6.0_03-b05
*************
JRE specification version : 1.6
--------------------------------------
If I again compile them like javac -source 1.3 -target 1.4 JVMVersion.java
and call them from an ant file to run. It returns different JDK version:
[java] Java Version : 1.4.2_05
[java] Java vendor : Sun Microsystems Inc.
[java] Java home : C:\Borland\BDP\jdk\jdk1.4.2\jre
[java] *************
[java] JVM specification version : 1.0
[java] JVM Version : 1.4.2_05-b04
[java] *************
[java] JRE specification version : 1.4
 
Rob Spoor
Sheriff
Pie
Posts: 20514
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What's the output of "echo %JAVA_HOME%" (or $JAVA_HOME for non-Windows OSes)?

The JAVA_HOME can point to a completely different JDK than the java(.exe) that is on the system path.
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

C:\Borland\BDP\jdk\jdk1.4.2\jre

You are not running Ant from JBuilder, are you?
 
Amir Pourteymour
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No I am not. Actually I have a separate folder for my ant, which my ANT_HOME is pointing to.
 
Amir Pourteymour
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Rob Prime:
What's the output of "echo %JAVA_HOME%" (or $JAVA_HOME for non-Windows OSes)?

The JAVA_HOME can point to a completely different JDK than the java(.exe) that is on the system path.



This is the output for that => C:\JAVA
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic