You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Rez P <po...@hotmail.com> on 2009/07/30 05:48:16 UTC

Building with JDK 1.3. Which version of ANT?

Hi

 

I'm going back in time and have to compile and old java project with JDK 1.3.  Currently I'm using Ant 1.7 and JDK 1.5 for all my projects. So when I wrote a build.xml for the jdk 1.3 code and in the compile target, using javac ant task, and set the 'source' or 'target' attributes to 1.3, I got errors that were not very clear to me, something like switch back to...  Does this mean I am using the wrong version of Ant and have to switch to 1.6 or earlier versions? 

 

 

C:\Temp\old_project>ant compile
Buildfile: build.xml

clean:
   [delete] Deleting directory C:\Temp\old_project\build

init:
    [mkdir] Created dir: C:\Temp\old_project\build\WEB-INF\classes\lib

jar_files:
     [echo] Copy jar files ...

compile:
     [echo] Building java classes ...
    [javac] Compiling 220 source files to C:\Temp\old_project\build\WEB-INF\classes
    [javac] Modern compiler not found - looking for classic compiler

BUILD FAILED
C:\Temp\old_project\build.xml:66: Cannot use classic compiler , as it is not available.
 A common solution is to set the environment variable JAVA_HOME to your jdk directory.
It is currently set to "C:\Progra~1\java\jdk1.3.1_20\jre"

Total time: 0 seconds

 

 

Thanks for your help.

 

Rez

_________________________________________________________________
Bing™ brings you maps, menus, and reviews organized in one place. Try it now.
http://www.bing.com/search?q=restaurants&form=MLOGEN&publ=WLHMTAG&crea=TXT_MLOGEN_Local_Local_Restaurants_1x1

Please give me your feedback on this article

Posted by "Bob.Aiello" <ra...@acm.org>.
Hi everyone,

recently, I had to write an Ant script that would run a Makefile and 
then catch the success or failure
of the Makefile (I had a mechanism to return this information to a 
Dashboard that showed
the Makefile success or failure). I wrote an article in CM Basics
( http://www.cmcrossroads.com/content/view/13261/120 ) on how to do this 
and I would appreciate
feedback from other people who Ant. Are there other ways to do this?

I found that some of the examples posted in other places actually did 
not work for me.
(One reason is that initializing the resultproperty="myStatus" variable 
could not be
overwritten in call.)

I am interested in whether or not there are other (better) ways of doing 
this.

Bob Aiello
Editor in Chief
CM Crossroads
http://www.linkedin.com/in/BobAiello


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


RE: Building with JDK 1.3. Which version of ANT?

Posted by Rez P <po...@hotmail.com>.
Thanks for the tip and the link Dale.

 


 
> Date: Thu, 30 Jul 2009 09:55:28 -0600
> Subject: Re: Building with JDK 1.3. Which version of ANT?
> From: danson@grafidog.com
> To: user@ant.apache.org
> 
> I ran into a similar problem just this morning with Java 1.5 and Java
> 1.6 incompatibility. In your javac task in your build file, you
> should also set the bootclasspath, and point it to the rt.jar for Java
> 1.3. This will help you not introduce usage of Java 1.5 APIs into
> your Java 1.3 build since the compiler will complain if it finds any.
> See the "Cross-Compilation Example" at the bottom of this page:
> 
> http://java.sun.com/javase/6/docs/technotes/tools/windows/javac.html
> 
> Dale
> 
> 
> On Thu, Jul 30, 2009 at 9:01 AM, Rez P<po...@hotmail.com> wrote:
> >
> > Thanks for all your help and input.
> >
> >
> >
> >
> >
> >> To: user@ant.apache.org
> >> Subject: Re: Building with JDK 1.3. Which version of ANT?
> >> From: bodewig@apache.org
> >> Date: Thu, 30 Jul 2009 12:11:45 +0200
> >>
> >> On 2009-07-30, Rez P <po...@hotmail.com> wrote:
> >>
> >> > I just got a successful build by using jdk 1.5, ant 1.7, and setting
> >> > source & target attributes of the javac ant task to 1.3. Do you see
> >> > any problem with this configuration as far as jdk 1.5 adding
> >> > unwanted stuff to my generated class files as opposed to, if I set
> >> > my entire environment to jdk 1.3 and making sure that the old
> >> > project doesn't become polluted with any new tools or libraries?
> >>
> >> One thing is that you might use classes or methods present in Java 1.5
> >> but not in 1.3 - this will compile on Java5 but fail if you try to run
> >> the code on 1.3. This may be possible to avoid if you are disciplined
> >> enough 8-)
> >>
> >> Unfortunately there are problems more subtle than that. If Java5 (or
> >> 1.4) have introduced new method overloads the compiler may choose one
> >> that doesn't exist in 1.3.
> >>
> >> One example that I've encountered myself
> >> StringBuffer.append(StringBuffer) which was added in Java 1.4. say
> >> you have
> >>
> >> StringBuffer sb1 = new StringBuffer();
> >> StringBuffer sb2 = new StringBuffer();
> >> sb2.append(sb1);
> >>
> >> This will compile fine on both JDKs. javac of JDK 1.3 (and earlier)
> >> will use append(Object), any later javac will use append(StringBuffer).
> >> Code compiled on Java 1.4 or later will throw an exception when run on
> >> Java 1.3 or earlier.
> >>
> >> These kinds of problems are way more difficult to catch when
> >> "cross-compiling".
> >>
> >> Stefan
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> >> For additional commands, e-mail: user-help@ant.apache.org
> >>
> >
> > _________________________________________________________________
> > Windows Live™ Hotmail®: Search, add, and share the web’s latest sports videos. Check it out.
> > http://www.windowslive.com/Online/Hotmail/Campaign/QuickAdd?ocid=TXT_TAGLM_WL_QA_HM_sports_videos_072009&cat=sports
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
> 

_________________________________________________________________
Get back to school stuff for them and cashback for you.
http://www.bing.com/cashback?form=MSHYCB&publ=WLHMTAG&crea=TEXT_MSHYCB_BackToSchool_Cashback_BTSCashback_1x1

Re: Building with JDK 1.3. Which version of ANT?

Posted by Dale Anson <da...@grafidog.com>.
I ran into a similar problem just this morning with Java 1.5 and Java
1.6 incompatibility.  In your javac task in your build file, you
should also set the bootclasspath, and point it to the rt.jar for Java
1.3.  This will help you not introduce usage of Java 1.5 APIs into
your Java 1.3 build since the compiler will complain if it finds any.
See the "Cross-Compilation Example" at the bottom of this page:

http://java.sun.com/javase/6/docs/technotes/tools/windows/javac.html

Dale


On Thu, Jul 30, 2009 at 9:01 AM, Rez P<po...@hotmail.com> wrote:
>
> Thanks for all your help and input.
>
>
>
>
>
>> To: user@ant.apache.org
>> Subject: Re: Building with JDK 1.3. Which version of ANT?
>> From: bodewig@apache.org
>> Date: Thu, 30 Jul 2009 12:11:45 +0200
>>
>> On 2009-07-30, Rez P <po...@hotmail.com> wrote:
>>
>> > I just got a successful build by using jdk 1.5, ant 1.7, and setting
>> > source & target attributes of the javac ant task to 1.3. Do you see
>> > any problem with this configuration as far as jdk 1.5 adding
>> > unwanted stuff to my generated class files as opposed to, if I set
>> > my entire environment to jdk 1.3 and making sure that the old
>> > project doesn't become polluted with any new tools or libraries?
>>
>> One thing is that you might use classes or methods present in Java 1.5
>> but not in 1.3 - this will compile on Java5 but fail if you try to run
>> the code on 1.3. This may be possible to avoid if you are disciplined
>> enough 8-)
>>
>> Unfortunately there are problems more subtle than that. If Java5 (or
>> 1.4) have introduced new method overloads the compiler may choose one
>> that doesn't exist in 1.3.
>>
>> One example that I've encountered myself
>> StringBuffer.append(StringBuffer) which was added in Java 1.4. say
>> you have
>>
>> StringBuffer sb1 = new StringBuffer();
>> StringBuffer sb2 = new StringBuffer();
>> sb2.append(sb1);
>>
>> This will compile fine on both JDKs. javac of JDK 1.3 (and earlier)
>> will use append(Object), any later javac will use append(StringBuffer).
>> Code compiled on Java 1.4 or later will throw an exception when run on
>> Java 1.3 or earlier.
>>
>> These kinds of problems are way more difficult to catch when
>> "cross-compiling".
>>
>> Stefan
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
>> For additional commands, e-mail: user-help@ant.apache.org
>>
>
> _________________________________________________________________
> Windows Live™ Hotmail®: Search, add, and share the web’s latest sports videos. Check it out.
> http://www.windowslive.com/Online/Hotmail/Campaign/QuickAdd?ocid=TXT_TAGLM_WL_QA_HM_sports_videos_072009&cat=sports

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


RE: Building with JDK 1.3. Which version of ANT?

Posted by Rez P <po...@hotmail.com>.
Thanks for all your help and input.

 


 
> To: user@ant.apache.org
> Subject: Re: Building with JDK 1.3. Which version of ANT?
> From: bodewig@apache.org
> Date: Thu, 30 Jul 2009 12:11:45 +0200
> 
> On 2009-07-30, Rez P <po...@hotmail.com> wrote:
> 
> > I just got a successful build by using jdk 1.5, ant 1.7, and setting
> > source & target attributes of the javac ant task to 1.3. Do you see
> > any problem with this configuration as far as jdk 1.5 adding
> > unwanted stuff to my generated class files as opposed to, if I set
> > my entire environment to jdk 1.3 and making sure that the old
> > project doesn't become polluted with any new tools or libraries?
> 
> One thing is that you might use classes or methods present in Java 1.5
> but not in 1.3 - this will compile on Java5 but fail if you try to run
> the code on 1.3. This may be possible to avoid if you are disciplined
> enough 8-)
> 
> Unfortunately there are problems more subtle than that. If Java5 (or
> 1.4) have introduced new method overloads the compiler may choose one
> that doesn't exist in 1.3.
> 
> One example that I've encountered myself
> StringBuffer.append(StringBuffer) which was added in Java 1.4. say
> you have
> 
> StringBuffer sb1 = new StringBuffer();
> StringBuffer sb2 = new StringBuffer();
> sb2.append(sb1);
> 
> This will compile fine on both JDKs. javac of JDK 1.3 (and earlier)
> will use append(Object), any later javac will use append(StringBuffer).
> Code compiled on Java 1.4 or later will throw an exception when run on
> Java 1.3 or earlier.
> 
> These kinds of problems are way more difficult to catch when
> "cross-compiling".
> 
> Stefan
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
> 

_________________________________________________________________
Windows Live™ Hotmail®: Search, add, and share the web’s latest sports videos. Check it out.
http://www.windowslive.com/Online/Hotmail/Campaign/QuickAdd?ocid=TXT_TAGLM_WL_QA_HM_sports_videos_072009&cat=sports

Re: Building with JDK 1.3. Which version of ANT?

Posted by Stefan Bodewig <bo...@apache.org>.
On 2009-07-30, Rez P <po...@hotmail.com> wrote:

> I just got a successful build by using jdk 1.5, ant 1.7, and setting
> source & target attributes of the javac ant task to 1.3.  Do you see
> any problem with this configuration as far as jdk 1.5 adding
> unwanted stuff to my generated class files as opposed to, if I set
> my entire environment to jdk 1.3 and making sure that the old
> project doesn't become polluted with any new tools or libraries?

One thing is that you might use classes or methods present in Java 1.5
but not in 1.3 - this will compile on Java5 but fail if you try to run
the code on 1.3.  This may be possible to avoid if you are disciplined
enough 8-)

Unfortunately there are problems more subtle than that.  If Java5 (or
1.4) have introduced new method overloads the compiler may choose one
that doesn't exist in 1.3.

One example that I've encountered myself
StringBuffer.append(StringBuffer) which was added in Java 1.4.  say
you have

    StringBuffer sb1 = new StringBuffer();
    StringBuffer sb2 = new StringBuffer();
    sb2.append(sb1);

This will compile fine on both JDKs.  javac of JDK 1.3 (and earlier)
will use append(Object), any later javac will use append(StringBuffer).
Code compiled on Java 1.4 or later will throw an exception when run on
Java 1.3 or earlier.

These kinds of problems are way more difficult to catch when
"cross-compiling".

Stefan

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


RE: Building with JDK 1.3. Which version of ANT?

Posted by Rez P <po...@hotmail.com>.
Thanks for the quick response Stefan.  That's the part I couldn't understand!  I did set my java_home to jdk 1.3! And added %java_home%\bin to my windows path variable.  I believe where Ant error msg is coming from is my java consol control panel pointing to jre 1.3 as I had unchecked and disabled the jre 1.5 temporarily.

 

I just got a successful build by using jdk 1.5, ant 1.7, and setting source & target attributes of the javac ant task to 1.3.  Do you see any problem with this configuration as far as jdk 1.5 adding unwanted stuff to my generated class files as opposed to, if I set my entire environment to jdk 1.3 and making sure that the old project doesn't become polluted with any new tools or libraries?

 

Thanks

 

Rez

 


 
> To: user@ant.apache.org
> Subject: Re: Building with JDK 1.3. Which version of ANT?
> From: bodewig@apache.org
> Date: Thu, 30 Jul 2009 06:35:20 +0200
> 
> On 2009-07-30, Rez P <po...@hotmail.com> wrote:
> 
> > I'm going back in time and have to compile and old java project with
> > JDK 1.3. Currently I'm using Ant 1.7 and JDK 1.5 for all my
> > projects. So when I wrote a build.xml for the jdk 1.3 code and in
> > the compile target, using javac ant task, and set the 'source' or
> > 'target' attributes to 1.3, I got errors that were not very clear to
> > me, something like switch back to... Does this mean I am using the
> > wrong version of Ant and have to switch to 1.6 or earlier versions?
> 
> No, not at all. 1.7 should work with JDK 1.3, 1.8.0 won't.
> 
> > [javac] Compiling 220 source files to C:\Temp\old_project\build\WEB-INF\classes
> > [javac] Modern compiler not found - looking for classic compiler
> 
> This means Ant tried to look up javac's main class of the compiler
> that was once the modern compiler - this is javac of JDK 1.2 IIRC,
> could be 1.3 as well - and failed.
> 
> classic in contrast is the main class of the javac version of JDK 1.1.
> 
> If Ant cannot find the modern compiler on JDK 1.3 it means it either
> failed to load tools.jar or you are not using a Sun JDK.
> 
> > BUILD FAILED
> > C:\Temp\old_project\build.xml:66: Cannot use classic compiler , as it is not available.
> > A common solution is to set the environment variable JAVA_HOME to your jdk directory.
> > It is currently set to "C:\Progra~1\java\jdk1.3.1_20\jre"
> 
> And here is your problem. Ant needs a JDK, not a JRE. Set JAVA_HOME
> to C:\Progra~1\java\jdk1.3.1_20 instead and Ant should be able to
> locate tools.jar.
> 
> Stefan
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
> 

_________________________________________________________________
NEW mobile Hotmail. Optimized for YOUR phone.  Click here.
http://windowslive.com/Mobile?ocid=TXT_TAGLM_WL_CS_MB_new_hotmail_072009

Re: Building with JDK 1.3. Which version of ANT?

Posted by Stefan Bodewig <bo...@apache.org>.
On 2009-07-30, Rez P <po...@hotmail.com> wrote:

> I'm going back in time and have to compile and old java project with
> JDK 1.3.  Currently I'm using Ant 1.7 and JDK 1.5 for all my
> projects. So when I wrote a build.xml for the jdk 1.3 code and in
> the compile target, using javac ant task, and set the 'source' or
> 'target' attributes to 1.3, I got errors that were not very clear to
> me, something like switch back to...  Does this mean I am using the
> wrong version of Ant and have to switch to 1.6 or earlier versions?

No, not at all.  1.7 should work with JDK 1.3, 1.8.0 won't.

>     [javac] Compiling 220 source files to C:\Temp\old_project\build\WEB-INF\classes
>     [javac] Modern compiler not found - looking for classic compiler

This means Ant tried to look up javac's main class of the compiler
that was once the modern compiler - this is javac of JDK 1.2 IIRC,
could be 1.3 as well - and failed.

classic in contrast is the main class of the javac version of JDK 1.1.

If Ant cannot find the modern compiler on JDK 1.3 it means it either
failed to load tools.jar or you are not using a Sun JDK.

> BUILD FAILED
> C:\Temp\old_project\build.xml:66: Cannot use classic compiler , as it is not available.
>  A common solution is to set the environment variable JAVA_HOME to your jdk directory.
> It is currently set to "C:\Progra~1\java\jdk1.3.1_20\jre"

And here is your problem.  Ant needs a JDK, not a JRE.  Set JAVA_HOME
to C:\Progra~1\java\jdk1.3.1_20 instead and Ant should be able to
locate tools.jar.

Stefan

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org