Deal of the Day

Home » Main » Manning Forums » 2003 » Eclipse in Action

Thread: Unable to find Javac compiler

Reply to this Thread Reply to this Thread Search Forum Search Forum Back to Thread List Back to Thread List

Permlink Replies: 5 - Pages: 1 - Last Post: Aug 5, 2003 11:00 PM by: import-bot
import-bot

Posts: 20,296
Registered: 12/6/03
Unable to find Javac compiler
Posted: Jul 30, 2003 11:00 PM
  Click to reply to this thread Reply

[Originally posted by jeph]

Hi!

My run ant build fails during compile. "Unable to find Javac compiler...
Perhaps JAVA_HOME does not point to JDK."

Am using XP. I have an environment variable with c:windowsjavain as the
contents - which is where javac.exe resides. The source compiles fine within
eclipse. (BTW this is the first book that I have bought where I haven't had
to debug the sample code - other than my own typos. Thanks for paying close
attenton to the details!)

Jeph


import-bot

Posts: 20,296
Registered: 12/6/03
Re: Unable to find Javac compiler
Posted: Jul 30, 2003 11:00 PM   in response to: import-bot in response to: import-bot
  Click to reply to this thread Reply

[Originally posted by dgallardo]

I don't understand what you mean about the environment variable, it looks like
it got garbled. In any case, the important thing is that you have a JDK (the
full Java development environment) installed and not a JRE, and that you have
the bin directory in your PATH environment variable. For example if you have
it installed in C:j2sdk1.4, then you would add C:j2sdkin to your PATH. (To
make sure you don't have another java.exe or javac.exe on your path before
this, you might want to add this as the first entry.) Eclipse and Ant can
figure everything else out (including the classpath) based on where it finds
java.exe.

As far as Ant is concerned, it doesn't matter what JAVA_HOME is set to,
despite what the error message says, as far as I can tell. Even if this is set
to a valid JDK, if you don't this JDKs bin directory on your path, you'll get
the message you describe.

Having said that, some other applications (like Tomcat) like to see the
JAVA_HOME variable. If you want to set it, it needs to points to the JDK's
base directory, e.g, C:j2sdk1.4, and not the bin directory.

In case you're wondering, Eclipse uses its own compiler (an incremental
compiler that allows it to do syntax checking etc. as you type). This is why
Eclipse can compile even though Ant can't. Unlike Ant, which has no compiler,
the only thing Eclipse needs is the JRE.

Hope that helps!

- David Gallardo


import-bot

Posts: 20,296
Registered: 12/6/03
Re: Unable to find Javac compiler
Posted: Jul 30, 2003 11:00 PM   in response to: import-bot in response to: import-bot
  Click to reply to this thread Reply

[Originally posted by dgallardo]

I see that the message board software likes to eat backslashes! I mean, of
course, that your PATH should be set to C:[backslash]j2sdk1.4[backslash]bin
and that JAVA_HOME should be set to C:[backslash]j2sdk1.4.


import-bot

Posts: 20,296
Registered: 12/6/03
Re: Unable to find Javac compiler
Posted: Aug 1, 2003 11:00 PM   in response to: import-bot in response to: import-bot
  Click to reply to this thread Reply

[Originally posted by jeph]

I downloaded and installed new j2sdk1.4.2 to c:\j2sdk1.4.2. I followed the
rest of your instructions - setting the c:\j2sdk1.4.2\bin directory at the
head of the path. Tried short name as well as long name. I replaced all
references to the old jdk with the new one in the classpath variable. I
removed an ANT_HOME variable from some experimental work I did with Xindice.
I renamed the old jdk directory so it would not be called by mistake... and
yet I still get the same results.

I must be overlooking something simple. Does anything else come to mind?

> I don't understand what you mean about the environment variable, it looks like
> it got garbled. In any case, the important thing is that you have a JDK (the
> full Java development environment) installed and not a JRE, and that you have
> the bin directory in your PATH environment variable. For example if you have
> it installed in C:j2sdk1.4, then you would add C:j2sdkin to your PATH. (To
> make sure you don't have another java.exe or javac.exe on your path before
> this, you might want to add this as the first entry.) Eclipse and Ant can
> figure everything else out (including the classpath) based on where it finds
> java.exe.
>
> As far as Ant is concerned, it doesn't matter what JAVA_HOME is set to,
> despite what the error message says, as far as I can tell. Even if this is set
> to a valid JDK, if you don't this JDKs bin directory on your path, you'll get
> the message you describe.
>
> Having said that, some other applications (like Tomcat) like to see the
> JAVA_HOME variable. If you want to set it, it needs to points to the JDK's
> base directory, e.g, C:j2sdk1.4, and not the bin directory.
>
> In case you're wondering, Eclipse uses its own compiler (an incremental
> compiler that allows it to do syntax checking etc. as you type). This is why
> Eclipse can compile even though Ant can't. Unlike Ant, which has no compiler,
> the only thing Eclipse needs is the JRE.
>
> Hope that helps!
>
> - David Gallardo


import-bot

Posts: 20,296
Registered: 12/6/03
Re: Unable to find Javac compiler
Posted: Aug 3, 2003 11:00 PM   in response to: import-bot in response to: import-bot
  Click to reply to this thread Reply

[Originally posted by burnette]

The fix that works for me is to locate tools.jar (it's somewhere in the jdk
directory) and add it to your Ant classpath (Window > Preferences > Ant >
Runtime > Classpath). Make sure you haven't overriden this global setting for
your particular ant xml file.


import-bot

Posts: 20,296
Registered: 12/6/03
Re: Unable to find Javac compiler
Posted: Aug 5, 2003 11:00 PM   in response to: import-bot in response to: import-bot
  Click to reply to this thread Reply

[Originally posted by jeph]

That works perfectly! In the mean time I was able to successfully compile
from the command line so I'm on to the next chapter.

Thanks!
Jeff

> The fix that works for me is to locate tools.jar (it's somewhere in the jdk
> directory) and add it to your Ant classpath (Window > Preferences > Ant >
> Runtime > Classpath). Make sure you haven't overriden this global setting for
> your particular ant xml file.


Legend
Gold: 300 + pts
Silver: 100 - 299 pts
Bronze: 25 - 99 pts
Manning Author
Manning Staff
Manning Developmental Editor