You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by pa...@webotech.co.uk on 2005/09/22 11:13:28 UTC

ant can't find javac compiler

Dear dev@ant.apache.org, 

I am using ant to compile my struts webapp. I am using Linux 2.4.27 and 
running ant (1.5.2-26) from my shell which is bash. My environment variables 
which I set in my .bash_profile are:
$JAVA_HOME=/usr/java/jdk1.5.0_02
$CLASSPATH=/usr/java/jdk1.5.0_02/lib:/usr/java/jdk1.5.0_02/jre/lib 

Here is my problem. When I compile my classes using the default compiler for 
my system (kjc) I get this error: 

error: Can't find default package `java.lang'. Check the CLASSPATH 
environment variable and the access to the archives 

Which I can live with (even though my CLASSPATH variable is probably 
correct) since I really ought to be using the jdk1.5.0_02 compiler. If I set 
the compiler attribute of <javac> task in my build.xml to modern, it should 
use the javac compiler that comes with my JDK. When I do I get this error: 

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 

If I run the javac command manually from the command prompt, something like 
this:
javac -cp MY/VERY/LONG/CLASSPATH/ src/uk/co/webotech/myproject/MyClass.java 

It compiles fine... By the way, typing "which javac" in my shell returns 
/usr/java/jdk1.5.0_02/bin/javac. How can I get ant to find javac? 

Any help with this would be greatly appreciated! 

Paul 


 --
Paul Mackinlay (PhD, MEng)
http://www.webotech.co.uk/
paul@webotech.co.uk
Tel: +44(0)7050 699971
Fax: +44(0)7050 699972

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


Re: ant can't find javac compiler

Posted by pa...@webotech.co.uk.
0. I'm on the user list now. 

1. Thanks - I'll try it and post results on the user list. 

Steve Loughran writes: 

> paul@webotech.co.uk wrote:
>> Martin,
>> I tried changing my $PATH as you suggested but that didn't help. Also, 
>> java and javac are both the same version (1.5.0_02).
>> I wonder if ant runs it's processes in another shell - one perhaps that 
>> doesn't pick up my personal env variables? Maybe it doesn't even run them 
>> in bash? Could it be that ant tasks are run by a different Linux user 
>> which needs to be set up?
>> I'm thinking out loud... if that is possible by email!
>> Paul
> 
> 0. this is more user space, not developer space questions. please send 
> follow messages to that mailing list. 
> 
> 1. I think you should run ant -diagnostics to see what Ant's view of the 
> world is 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
> For additional commands, e-mail: dev-help@ant.apache.org 
> 
 


 --
Paul Mackinlay (PhD, MEng)
http://www.webotech.co.uk/
paul@webotech.co.uk
Tel: +44(0)7050 699971
Fax: +44(0)7050 699972 


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


Re: ant can't find javac compiler

Posted by Steve Loughran <st...@apache.org>.
paul@webotech.co.uk wrote:
> Martin,
> I tried changing my $PATH as you suggested but that didn't help. Also, 
> java and javac are both the same version (1.5.0_02).
> I wonder if ant runs it's processes in another shell - one perhaps that 
> doesn't pick up my personal env variables? Maybe it doesn't even run 
> them in bash? Could it be that ant tasks are run by a different Linux 
> user which needs to be set up?
> I'm thinking out loud... if that is possible by email!
> Paul

0. this is more user space, not developer space questions. please send 
follow messages to that mailing list.

1. I think you should run ant -diagnostics to see what Ant's view of the 
world is

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


Re: ant can't find javac compiler

Posted by Martin Gainty <mg...@hotmail.com>.
Good Afternoon Paul
The documentation for the ant javac task is available at
http://ant.apache.org/manual/CoreTasks/javac.html
2 things..
set fork = "yes"
take a look at the parameter called executable
Complete path to the javac executable to use in case of fork="yes"
HTH,
Martin-
----- Original Message ----- 
From: <pa...@webotech.co.uk>
To: "Ant Developers List" <de...@ant.apache.org>
Sent: Thursday, September 22, 2005 10:27 AM
Subject: Re: ant can't find javac compiler


> Martin,
> I tried changing my $PATH as you suggested but that didn't help. Also, 
> java and javac are both the same version (1.5.0_02).
> I wonder if ant runs it's processes in another shell - one perhaps that 
> doesn't pick up my personal env variables? Maybe it doesn't even run them 
> in bash? Could it be that ant tasks are run by a different Linux user 
> which needs to be set up?
> I'm thinking out loud... if that is possible by email!
> Paul
>
> Martin Gainty writes:
>> Paul-
>> 2 things that I would look for move "$JAVA_HOME\bin" to front of $PATH 
>> make sure your JRE and JDK(SDK) are the same version
>> e.g.
>> javac -version Test.java
>> java -version
>> SHOULD report the same version Anyone else ??? Martin Gainty
>> (mobile) 617-852-7822
>> (http)www.laconiadatasystems.com
>>>
>>> Dear dev@ant.apache.org, I am using ant to compile my struts webapp. I 
>>> am using Linux 2.4.27 and running ant (1.5.2-26) from my shell which is 
>>> bash. My environment variables which I set in my .bash_profile are:
>>> $JAVA_HOME=/usr/java/jdk1.5.0_02
>>> $CLASSPATH=/usr/java/jdk1.5.0_02/lib:/usr/java/jdk1.5.0_02/jre/lib Here 
>>> is my problem. When I compile my classes using the default compiler for 
>>> my system (kjc) I get this error: error: Can't find default package 
>>> `java.lang'. Check the CLASSPATH environment variable and the access to 
>>> the archives Which I can live with (even though my CLASSPATH variable is 
>>> probably correct) since I really ought to be using the jdk1.5.0_02 
>>> compiler. If I set the compiler attribute of <javac> task in my 
>>> build.xml to modern, it should use the javac compiler that comes with my 
>>> JDK. When I do I get this error: 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 If I run the javac command 
>>> manually from the command prompt, something like this:
>>> javac -cp MY/VERY/LONG/CLASSPATH/ 
>>> src/uk/co/webotech/myproject/MyClass.java It compiles fine... By the 
>>> way, typing "which javac" in my shell returns 
>>> /usr/java/jdk1.5.0_02/bin/javac. How can I get ant to find javac? Any 
>>> help with this would be greatly appreciated! Paul --
>>> Paul Mackinlay (PhD, MEng)
>>> http://www.webotech.co.uk/
>>> paul@webotech.co.uk
>>> Tel: +44(0)7050 699971
>>> Fax: +44(0)7050 
>>> 699972 ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
>>> For additional commands, e-mail: dev-help@ant.apache.org
>>  ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
>> For additional commands, e-mail: dev-help@ant.apache.org
>
>
>
> --
> Paul Mackinlay (PhD, MEng)
> http://www.webotech.co.uk/
> paul@webotech.co.uk
> Tel: +44(0)7050 699971
> Fax: +44(0)7050 699972
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
> For additional commands, e-mail: dev-help@ant.apache.org
>
> 

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


Re: ant can't find javac compiler

Posted by pa...@webotech.co.uk.
Martin, 

I tried changing my $PATH as you suggested but that didn't help. Also, java 
and javac are both the same version (1.5.0_02). 

I wonder if ant runs it's processes in another shell - one perhaps that 
doesn't pick up my personal env variables? Maybe it doesn't even run them in 
bash? Could it be that ant tasks are run by a different Linux user which 
needs to be set up? 

I'm thinking out loud... if that is possible by email! 

Paul 


Martin Gainty writes: 

> Paul-
> 2 things that I would look for 
> 
> move "$JAVA_HOME\bin" to front of $PATH 
> 
> make sure your JRE and JDK(SDK) are the same version
> e.g.
> javac -version Test.java
> java -version
> SHOULD report the same version 
> 
> Anyone else ??? 
> 
> Martin Gainty
> (mobile) 617-852-7822
> (http)www.laconiadatasystems.com 
> 
>> 
>> Dear dev@ant.apache.org, 
>> 
>> I am using ant to compile my struts webapp. I am using Linux 2.4.27 and 
>> running ant (1.5.2-26) from my shell which is bash. My environment 
>> variables which I set in my .bash_profile are:
>> $JAVA_HOME=/usr/java/jdk1.5.0_02
>> $CLASSPATH=/usr/java/jdk1.5.0_02/lib:/usr/java/jdk1.5.0_02/jre/lib 
>> 
>> Here is my problem. When I compile my classes using the default compiler 
>> for my system (kjc) I get this error: 
>> 
>> error: Can't find default package `java.lang'. Check the CLASSPATH 
>> environment variable and the access to the archives 
>> 
>> Which I can live with (even though my CLASSPATH variable is probably 
>> correct) since I really ought to be using the jdk1.5.0_02 compiler. If I 
>> set the compiler attribute of <javac> task in my build.xml to modern, it 
>> should use the javac compiler that comes with my JDK. When I do I get 
>> this error: 
>> 
>> 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 
>> 
>> If I run the javac command manually from the command prompt, something 
>> like this:
>> javac -cp MY/VERY/LONG/CLASSPATH/ 
>> src/uk/co/webotech/myproject/MyClass.java 
>> 
>> It compiles fine... By the way, typing "which javac" in my shell returns 
>> /usr/java/jdk1.5.0_02/bin/javac. How can I get ant to find javac? 
>> 
>> Any help with this would be greatly appreciated! 
>> 
>> Paul 
>> 
>> 
>> --
>> Paul Mackinlay (PhD, MEng)
>> http://www.webotech.co.uk/
>> paul@webotech.co.uk
>> Tel: +44(0)7050 699971
>> Fax: +44(0)7050 699972 
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
>> For additional commands, e-mail: dev-help@ant.apache.org 
>> 
>  
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
> For additional commands, e-mail: dev-help@ant.apache.org 
> 
 


 --
Paul Mackinlay (PhD, MEng)
http://www.webotech.co.uk/
paul@webotech.co.uk
Tel: +44(0)7050 699971
Fax: +44(0)7050 699972 


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


RE: ant can't find javac compiler

Posted by Martin Gainty <mg...@hotmail.com>.
Paul-
2 things that I would look for

move "$JAVA_HOME\bin" to front of $PATH

make sure your JRE and JDK(SDK) are the same version
e.g.
javac -version Test.java
java -version
SHOULD report the same version

Anyone else ???

Martin Gainty
(mobile) 617-852-7822
(http)www.laconiadatasystems.com

>
>Dear dev@ant.apache.org,
>
>I am using ant to compile my struts webapp. I am using Linux 2.4.27 and 
>running ant (1.5.2-26) from my shell which is bash. My environment 
>variables which I set in my .bash_profile are:
>$JAVA_HOME=/usr/java/jdk1.5.0_02
>$CLASSPATH=/usr/java/jdk1.5.0_02/lib:/usr/java/jdk1.5.0_02/jre/lib
>
>Here is my problem. When I compile my classes using the default compiler 
>for my system (kjc) I get this error:
>
>error: Can't find default package `java.lang'. Check the CLASSPATH 
>environment variable and the access to the archives
>
>Which I can live with (even though my CLASSPATH variable is probably 
>correct) since I really ought to be using the jdk1.5.0_02 compiler. If I 
>set the compiler attribute of <javac> task in my build.xml to modern, it 
>should use the javac compiler that comes with my JDK. When I do I get this 
>error:
>
>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
>
>If I run the javac command manually from the command prompt, something like 
>this:
>javac -cp MY/VERY/LONG/CLASSPATH/ src/uk/co/webotech/myproject/MyClass.java
>
>It compiles fine... By the way, typing "which javac" in my shell returns 
>/usr/java/jdk1.5.0_02/bin/javac. How can I get ant to find javac?
>
>Any help with this would be greatly appreciated!
>
>Paul
>
>
>--
>Paul Mackinlay (PhD, MEng)
>http://www.webotech.co.uk/
>paul@webotech.co.uk
>Tel: +44(0)7050 699971
>Fax: +44(0)7050 699972
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
>For additional commands, e-mail: dev-help@ant.apache.org
>



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