You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Oliver Schalch <ol...@wyona.com> on 2006/04/03 16:19:22 UTC

Javac tasks (when calling from java)

Hi List, 

Another Problem...

Calling ant from Java (inside a bigger project)

Unable to find a javac compiler; com.sun.tools.javac.Main is not on the
classpath. Perhaps JAVA_HOME does not point to the JDK

Alright, ofcourse the JAVA_HOME are set correct.

How could I fix that?

Do I have to write a own classloader with the tools.jar in it, and use
it with project#setClassLoader ?

Any hints, please.


Thanks
Oliver



-- 
Oliver Schalch                           oliver.schalch@wyona.com
Wyona Inc.  -   Open Source Content Management   -   Apache Lenya
http://www.wyona.com                      http://lenya.apache.org

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


RE: Javac tasks (when calling from java)

Posted by Stephen McConnell <mc...@dpml.net>.
 

> -----Original Message-----
> From: Oliver Schalch [mailto:oliver.schalch@wyona.com] 
> Sent: Monday, 3 April 2006 11:49 PM
> To: user@ant.apache.org
> Subject: Javac tasks (when calling from java)
> 
> Hi List, 
> 
> Another Problem...
> 
> Calling ant from Java (inside a bigger project)
> 
> Unable to find a javac compiler; com.sun.tools.javac.Main is 
> not on the classpath. Perhaps JAVA_HOME does not point to the JDK
> 
> Alright, ofcourse the JAVA_HOME are set correct.
> 
> How could I fix that?
> 
> Do I have to write a own classloader with the tools.jar in 
> it, and use it with project#setClassLoader ?

The application that is calling ant (and specifically the javac task) must
be established within a classloader that either contains tools.jar, or has
access to tools.jar somewhere in the parent classloader chain.  If you have
control over the system classloader then it's reasonably easy to trigger the
automatic loading of tools.jar on application startup.  

/Steve.



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


RE: Javac tasks (when calling from java)

Posted by Stephen McConnell <mc...@dpml.net>.
 

> -----Original Message-----
> From: Joe Moore [mailto:i_bugsy@yahoo.com] 
> Sent: Tuesday, 4 April 2006 2:40 AM
> To: Ant Users List
> Subject: Re: Javac tasks (when calling from java)
> 
> I've noticed that with Java 5, when you install it it 
> installs the JDK in a separate folde than the SDK I think it 
> used to be a subfolder of the SDK but is now its own separate 
> folder. This then puts the tools.jar in the SDK and outside 
> the CLASSPATH.

The following logic works for me under both 1.4 and 1.5:

   File jre = new File( System.getProperty( "java.home" ) );
   File jdk = jre.getParentFile();
   File lib = new File( jdk, "lib" );
   File tools = new File( lib, "tools.jar" );

/Steve.


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


Re: Javac tasks (when calling from java)

Posted by Matt Benson <gu...@yahoo.com>.
Correct, as far as Ant is concerned, you should set
JAVA_HOME to the location of the Java SDK.  That
assumes you want to use things from tools.jar .  If
you were using a different compiler, e.g. jikes or
jdt, you might get by without tools.jar and thus
JAVA_HOME could safely point to a JRE.  But for normal
out-of-the-box Java Ant builds, point JAVA_HOME to the
SDK.

See
http://ant.apache.org/manual/install.html#installing
under "Setup".

-Matt

--- Joe Moore <i_...@yahoo.com> wrote:

> My error, JDK and SDK are synonymous. I meant JRE
> and SDK are installed in separate directories.
> I was mentioning that in case the person who had
> posted their problem may have had the same
> experience and therefore the tools.jar file is not
> in their classpath.
> 
> Joe Moorei_bugsy@yahoo.com
> 
> ----- Original Message ----
> From: Matt Benson <gu...@yahoo.com>
> To: Ant Users List <us...@ant.apache.org>; Joe Moore
> <i_...@yahoo.com>
> Sent: Monday, April 3, 2006 1:14:46 PM
> Subject: Re: Javac tasks (when calling from java)
> 
> It would probably help if you give examples of the
> directories you are referring to.  As far as I ever
> knew JDK and SDK were synonymous in terms of Java.
> 
> -Matt
> 
> --- Joe Moore <i_...@yahoo.com> wrote:
> 
> > I've noticed that with Java 5, when you install it
> > it installs the JDK in a separate folde than the
> SDK
> > I think it used to be a subfolder of the SDK but
> is
> > now its own separate folder. This then puts the
> > tools.jar in the SDK and outside the CLASSPATH.
> > As a workaround I've added the full path to the
> > tools.jar file and that has resolved the issue.
> Not
> > sure if this is the best way, but something to
> look
> > for.
> > 
> > Anyone else have this experience with Java 1.5?
> > 
> > HTH,
> >  
> > Joe Moorei_bugsy@yahoo.com
> > 
> > ----- Original Message ----
> > From: Oliver Schalch <ol...@wyona.com>
> > To: user@ant.apache.org
> > Sent: Monday, April 3, 2006 10:19:22 AM
> > Subject: Javac tasks (when calling from java)
> > 
> > Hi List, 
> > 
> > Another Problem...
> > 
> > Calling ant from Java (inside a bigger project)
> > 
> > Unable to find a javac compiler;
> > com.sun.tools.javac.Main is not on the
> > classpath. Perhaps JAVA_HOME does not point to the
> > JDK
> > 
> > Alright, ofcourse the JAVA_HOME are set correct.
> > 
> > How could I fix that?
> > 
> > Do I have to write a own classloader with the
> > tools.jar in it, and use
> > it with project#setClassLoader ?
> > 
> > Any hints, please.
> > 
> > 
> > Thanks
> > Oliver
> > 
> > 
> > 
> > -- 
> > Oliver Schalch                          
> > oliver.schalch@wyona.com
> > Wyona Inc.  -   Open Source Content Management   -
>  
> > Apache Lenya
> > http://www.wyona.com                     
> > http://lenya.apache.org
> > 
> >
>
---------------------------------------------------------------------
> > To unsubscribe, e-mail:
> > user-unsubscribe@ant.apache.org
> > For additional commands, e-mail:
> > user-help@ant.apache.org
> > 
> > 
> > 
> > 
> > 
> > 
> >
>
---------------------------------------------------------------------
> > To unsubscribe, e-mail:
> > user-unsubscribe@ant.apache.org
> > For additional commands, e-mail:
> > user-help@ant.apache.org
> > 
> > 
> 
> 
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam
> protection around 
> http://mail.yahoo.com 
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> user-unsubscribe@ant.apache.org
> For additional commands, e-mail:
> user-help@ant.apache.org
> 
> 
> 
> 
> 
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> user-unsubscribe@ant.apache.org
> For additional commands, e-mail:
> user-help@ant.apache.org
> 
> 


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

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


Re: Javac tasks (when calling from java)

Posted by Joe Moore <i_...@yahoo.com>.
My error, JDK and SDK are synonymous. I meant JRE and SDK are installed in separate directories.
I was mentioning that in case the person who had posted their problem may have had the same experience and therefore the tools.jar file is not in their classpath.

Joe Moorei_bugsy@yahoo.com

----- Original Message ----
From: Matt Benson <gu...@yahoo.com>
To: Ant Users List <us...@ant.apache.org>; Joe Moore <i_...@yahoo.com>
Sent: Monday, April 3, 2006 1:14:46 PM
Subject: Re: Javac tasks (when calling from java)

It would probably help if you give examples of the
directories you are referring to.  As far as I ever
knew JDK and SDK were synonymous in terms of Java.

-Matt

--- Joe Moore <i_...@yahoo.com> wrote:

> I've noticed that with Java 5, when you install it
> it installs the JDK in a separate folde than the SDK
> I think it used to be a subfolder of the SDK but is
> now its own separate folder. This then puts the
> tools.jar in the SDK and outside the CLASSPATH.
> As a workaround I've added the full path to the
> tools.jar file and that has resolved the issue. Not
> sure if this is the best way, but something to look
> for.
> 
> Anyone else have this experience with Java 1.5?
> 
> HTH,
>  
> Joe Moorei_bugsy@yahoo.com
> 
> ----- Original Message ----
> From: Oliver Schalch <ol...@wyona.com>
> To: user@ant.apache.org
> Sent: Monday, April 3, 2006 10:19:22 AM
> Subject: Javac tasks (when calling from java)
> 
> Hi List, 
> 
> Another Problem...
> 
> Calling ant from Java (inside a bigger project)
> 
> Unable to find a javac compiler;
> com.sun.tools.javac.Main is not on the
> classpath. Perhaps JAVA_HOME does not point to the
> JDK
> 
> Alright, ofcourse the JAVA_HOME are set correct.
> 
> How could I fix that?
> 
> Do I have to write a own classloader with the
> tools.jar in it, and use
> it with project#setClassLoader ?
> 
> Any hints, please.
> 
> 
> Thanks
> Oliver
> 
> 
> 
> -- 
> Oliver Schalch                          
> oliver.schalch@wyona.com
> Wyona Inc.  -   Open Source Content Management   -  
> Apache Lenya
> http://www.wyona.com                     
> http://lenya.apache.org
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> user-unsubscribe@ant.apache.org
> For additional commands, e-mail:
> user-help@ant.apache.org
> 
> 
> 
> 
> 
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> user-unsubscribe@ant.apache.org
> For additional commands, e-mail:
> user-help@ant.apache.org
> 
> 


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

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






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


Re: Javac tasks (when calling from java)

Posted by Matt Benson <gu...@yahoo.com>.
It would probably help if you give examples of the
directories you are referring to.  As far as I ever
knew JDK and SDK were synonymous in terms of Java.

-Matt

--- Joe Moore <i_...@yahoo.com> wrote:

> I've noticed that with Java 5, when you install it
> it installs the JDK in a separate folde than the SDK
> I think it used to be a subfolder of the SDK but is
> now its own separate folder. This then puts the
> tools.jar in the SDK and outside the CLASSPATH.
> As a workaround I've added the full path to the
> tools.jar file and that has resolved the issue. Not
> sure if this is the best way, but something to look
> for.
> 
> Anyone else have this experience with Java 1.5?
> 
> HTH,
>  
> Joe Moorei_bugsy@yahoo.com
> 
> ----- Original Message ----
> From: Oliver Schalch <ol...@wyona.com>
> To: user@ant.apache.org
> Sent: Monday, April 3, 2006 10:19:22 AM
> Subject: Javac tasks (when calling from java)
> 
> Hi List, 
> 
> Another Problem...
> 
> Calling ant from Java (inside a bigger project)
> 
> Unable to find a javac compiler;
> com.sun.tools.javac.Main is not on the
> classpath. Perhaps JAVA_HOME does not point to the
> JDK
> 
> Alright, ofcourse the JAVA_HOME are set correct.
> 
> How could I fix that?
> 
> Do I have to write a own classloader with the
> tools.jar in it, and use
> it with project#setClassLoader ?
> 
> Any hints, please.
> 
> 
> Thanks
> Oliver
> 
> 
> 
> -- 
> Oliver Schalch                          
> oliver.schalch@wyona.com
> Wyona Inc.  -   Open Source Content Management   -  
> Apache Lenya
> http://www.wyona.com                     
> http://lenya.apache.org
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> user-unsubscribe@ant.apache.org
> For additional commands, e-mail:
> user-help@ant.apache.org
> 
> 
> 
> 
> 
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> user-unsubscribe@ant.apache.org
> For additional commands, e-mail:
> user-help@ant.apache.org
> 
> 


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

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


Re: Javac tasks (when calling from java)

Posted by Joe Moore <i_...@yahoo.com>.
I've noticed that with Java 5, when you install it it installs the JDK in a separate folde than the SDK I think it used to be a subfolder of the SDK but is now its own separate folder. This then puts the tools.jar in the SDK and outside the CLASSPATH.
As a workaround I've added the full path to the tools.jar file and that has resolved the issue. Not sure if this is the best way, but something to look for.

Anyone else have this experience with Java 1.5?

HTH,
 
Joe Moorei_bugsy@yahoo.com

----- Original Message ----
From: Oliver Schalch <ol...@wyona.com>
To: user@ant.apache.org
Sent: Monday, April 3, 2006 10:19:22 AM
Subject: Javac tasks (when calling from java)

Hi List, 

Another Problem...

Calling ant from Java (inside a bigger project)

Unable to find a javac compiler; com.sun.tools.javac.Main is not on the
classpath. Perhaps JAVA_HOME does not point to the JDK

Alright, ofcourse the JAVA_HOME are set correct.

How could I fix that?

Do I have to write a own classloader with the tools.jar in it, and use
it with project#setClassLoader ?

Any hints, please.


Thanks
Oliver



-- 
Oliver Schalch                           oliver.schalch@wyona.com
Wyona Inc.  -   Open Source Content Management   -   Apache Lenya
http://www.wyona.com                      http://lenya.apache.org

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






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