Skip to content
Advertisement

error=2, No such file or directory at java.lang.ProcessBuilder.start

I’m using Fedora 18 and JDK 1.7.13 installed in /usr/java. All executable files under bin folder have -rwxr-xr-x permission. I set both ANT_HOME and JAVA_HOME in my ~/.bashrc as:

export ANT_HOME=/home/m/application/apache-ant-1.8.2
export JAVA_HOME=/usr/java/jdk1.7.0_13/

and I have a build.xml file which says:

<exec dir="${java.home}/bin/" executable="keytool"/>

but after running ant I got this exception:

/home/m/workspace/build.xml:58: Execute failed: java.io.IOException: Cannot run program “keytool” (in directory “/usr/java/jdk1.7.0_13/jre/bin”): error=2, No such file or directory at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029) at java.lang.Runtime.exec(Runtime.java:615) at org.apache.tools.ant.taskdefs.Execute$Java13CommandLauncher.exec(Execute.java:827) at org.apache.tools.ant.taskdefs.Execute.launch(Execute.java:445) . . .

at org.apache.tools.ant.launch.Launcher.main(Launcher.java:109)

Any idea?

Advertisement

Answer

Try:

  • export ANT_HOME=/path/to/ant

  • export PATH=$ANT_HOME/bin:$PATH

  • <exec executable="keytool"/>

or:

<exec executable="${java.home}/bin/keytool"/>

As the dir attribute tells Ant in which directory to execute the binary, not what the path to it is.

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement