aspose file tools*
The moose likes Ant, Maven and Other Build Tools and the fly likes Problem with running my class inside ANT Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "Problem with running my class inside ANT" Watch "Problem with running my class inside ANT" New topic
Author

Problem with running my class inside ANT

Amir Pourteymour
Ranch Hand

Joined: Mar 06, 2008
Posts: 45
Hi,
I have a simple class, which shows JDK and java related versions. I got three different behavior in different situations. I found out when I run my class separately it gives me a different JDK version than when I call my class inside an ANT file.

It clearly shows that in my system, ANT uses JDK 1.4 inside my code. I checked my ant, and there is no place that I point to a specific JDK. I guess it uses that by default.

Does anybody have any idea about this?

When I compile my class like this :
javac -source 1.4 -target 1.5 JVMVersion.java
it gives me error of "java.lang.UnsupportedClassVersionError: JVMVersion (Unsupported major.minor version 49.0)"

------------------------------------
if I compile them 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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problem with running my class inside ANT