You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Andy Wickson <an...@gmail.com> on 2005/09/15 11:31:06 UTC

Specifying the java runtime for Ant

Hi,

I know that using <javac ..... executable=<PATH TO JAVAC>
I can specify the javac that I want to use for a compilation but is it 
possible to do this the other way round?

I.e., I want to explicitly specify to Ant the runtime to use for itself at 
startup (one which it won't find as default in the $PATH) and then use the 
default javac for the compilation itself. 

Thanks,
Andy

Re: Specifying the java runtime for Ant

Posted by Steve Loughran <st...@hpl.hp.com>.
Andy Wickson wrote:
> I am really trying to get Ant itself to run using a non-default java runtime 
> (one I specify). The reasons are very convoluted and I won't bore you with 
> them.
> There seems to be something in the docs about this but I get the feeling 
> things may have changed recently. I have seen talk of a .antrc file in which 
> you can specify env. vars. such as JAVACMD but i have no such file. The 
> manual also mentions running from java which may of help but I've tried 
> every combination of the following:
> java/142/bin/java -Dant.home=$$ANT_HOME org.apache.tools.ant.Main
> java/142/bin/java -Dant.home=apache-ant-1.6.5/bin/ant 
> org.apache.tools.ant.Main
> etc
> but always get:
> The java class is not found: org/apache/tools/ant/Main
> even though i can see it there in the jar file.

well, that's because you arent setting your classpath up. you want 
"java" to run a java program, you have to name the jars that it loads.

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


Re: Specifying the java runtime for Ant

Posted by Andy Wickson <an...@gmail.com>.
I am really trying to get Ant itself to run using a non-default java runtime 
(one I specify). The reasons are very convoluted and I won't bore you with 
them.
There seems to be something in the docs about this but I get the feeling 
things may have changed recently. I have seen talk of a .antrc file in which 
you can specify env. vars. such as JAVACMD but i have no such file. The 
manual also mentions running from java which may of help but I've tried 
every combination of the following:
java/142/bin/java -Dant.home=$$ANT_HOME org.apache.tools.ant.Main
java/142/bin/java -Dant.home=apache-ant-1.6.5/bin/ant 
org.apache.tools.ant.Main
etc
but always get:
The java class is not found: org/apache/tools/ant/Main
even though i can see it there in the jar file.

Thanks,
Andy




On 9/15/05, Barry White <bw...@fotango.com> wrote:
> 
> Hi Andy,
> 
> are you just trying to ensure that your sources will compile to be, say,
> 1.3 compliant? This was a problem that I faced for a while and I believe
> it was solved on this mailing list. I thought specifying
> source/target=1.3 should or would be enough but it is not - you have to
> specify the bootclasspath:
> 
> <javac source="1.3"
> target="1.3"
> bootclasspath="C:/Java/jdk1.3.1_16/jre/lib/rt.jar"
> srcdir="${source}"
> destdir="${classes}" />
> 
> Hoping that this was your problem ;)
> 
> Barry
> 
> Andy Wickson wrote:
> > Hi,
> >
> > I know that using <javac ..... executable=<PATH TO JAVAC>
> > I can specify the javac that I want to use for a compilation but is it
> > possible to do this the other way round?
> >
> > I.e., I want to explicitly specify to Ant the runtime to use for itself 
> at
> > startup (one which it won't find as default in the $PATH) and then use 
> the
> > default javac for the compilation itself.
> >
> > Thanks,
> > Andy
> >
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
> 
>

Re: Specifying the java runtime for Ant

Posted by Barry White <bw...@fotango.com>.
Hi Andy,

are you just trying to ensure that your sources will compile to be, say, 
1.3 compliant? This was a problem that I faced for a while and I believe 
it was solved on this mailing list. I thought specifying 
source/target=1.3 should or would be enough but it is not - you have to 
specify the bootclasspath:

<javac source="1.3"
        target="1.3"
        bootclasspath="C:/Java/jdk1.3.1_16/jre/lib/rt.jar"
        srcdir="${source}"
        destdir="${classes}" />

Hoping that this was your problem ;)

Barry

Andy Wickson wrote:
> Hi,
> 
> I know that using <javac ..... executable=<PATH TO JAVAC>
> I can specify the javac that I want to use for a compilation but is it 
> possible to do this the other way round?
> 
> I.e., I want to explicitly specify to Ant the runtime to use for itself at 
> startup (one which it won't find as default in the $PATH) and then use the 
> default javac for the compilation itself. 
> 
> Thanks,
> Andy
> 

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


Re: Specifying the java runtime for Ant

Posted by Steve Loughran <st...@apache.org>.
Andy Wickson wrote:
> Hi,
> 
> I know that using <javac ..... executable=<PATH TO JAVAC>
> I can specify the javac that I want to use for a compilation but is it 
> possible to do this the other way round?
> 
> I.e., I want to explicitly specify to Ant the runtime to use for itself at 
> startup (one which it won't find as default in the $PATH) and then use the 
> default javac for the compilation itself. 
> 

lets think about this for a minute.

you want an option, presumably something like -runtime=1.4 or 
-runtime=/usr/share/java/1.4 which ant (a java program) will use to 
determine the runtime it runs under.

i.e. you want a java program to be able to dynamically decide which 
runtime to run under.

This isnt possible. Which leaves making changes to the java startup 
scripts. Those scripts are scary and complex enough as it is, believe 
me, and they lead to many more support calls than 200 lines of code 
ought to, especially from systems/configurations you dont expect to be 
running Ant.

Its much easier just to edit the path. Have some script that changes 
your JAVA_HOME, JDK_HOME, PATH env options for a particular shell; run 
that in whichever shell you want to call ant from later.

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