I have my javac
under my project directory. Lets say at C:\workspace\myworkspace\java\bin\javac
what i want to do is, in ant, use that particular javac for building. so i do
<exec executable="java\bin\javac">
<exec>
but my eclipse keep complaining
BUILD FAILED
C:\workspace\myworkspace\build.xml:7: Execute failed: java.io.IOException: Cannot run program "java\bin\javac" (in directory "C:\workspace\myworkspace"): CreateProcess error=2, The system cannot find the file specified
what is wrong? I went to directory C:\workspace\myworkspace\java\bin\ and do javac and it works,
but i cant do
C:\workspace\myworkspace\java\bin\java
from command line.
What is different on Windows? I normally work on linux so I don't know how to make it right on windows.
To add a bit more, I don't want add this java to my $PATH, because it's particular for this project only, and i dont want to mess up with my other java executables.
Two potential problems...
Firstly, it's possible that this:
<exec executable="java\bin\javac">
... is making Ant look for a file called java\bin\javac
within the directory c:\workspace\myworkspace
, where it doesn't exist. It's javac
within c:\workspace\myworkspace\java\bin
, which isn't quite the same thing.
As per the exec
documentation you might want to use a <property>
with a location
attribute to resolve the file.
Secondly, it's possible that it's being confused by looking for javac
when the executable is actually called javac.exe
. The .exe
extension is checked for by the command shell, but I don't think Runtime.exec
will do the same thing.
Also, as Braj mentioned in comments, you'd be better off using Ant's built-in support for javac
...
See more on this question at Stackoverflow