developer
developer

Reputation: 9478

Build error using Ant build tool "can't open file 'C:\Program': [Errno 2] No such file or directory"

I configured Python to path variable, below is the path variable content

%systemroot%\system32;%systemroot%;%systemroot%\system32\wbem;%systemroot%\system32\windowspowershell\v1.0\;C:\Python27\;c:\program files\java\jdk1.7.0_03\bin;.;c:\program files\tortoisesvn\bin;d:\apache-ant-1.8.3\bin;c:\program files\ibm\gsk8\lib;C:\PROGRA~1\IBM\SQLLIB\BIN;C:\PROGRA~1\IBM\SQLLIB\FUNCTION;C:\PROGRA~1\IBM\SQLLIB\SAMPLES\REPL;%M2_HOME%\bin;C:\Program Files\Lenovo\Bluetooth Software\;

Why I configured Python means, i am creating exe file using ant build and installj

<target name="installer.izpack.exe" depends="installer.izpack" description="build release executable izpack installer">
    <exec executable="python" failonerror="true">
        <arg line="${installer.izpack.dir}/utils/wrappers/izpack2exe/izpack2exe.py"/>
        <arg line="--file=${basedir}/installer/EasyIT-installer.jar"/>
        <arg line="--output=${basedir}/installer/EasyIT-installer.exe"/>
        <arg line="--no-upx"/>
    </exec>
</target>

but when building the app getting below error:

installer.izpack.exe:
     [exec] python: can't open file 'C:\Program': [Errno 2] No such file or directory

BUILD FAILED
E:\Java Projects\Spark Projects\EastIT - Copy\build\build.xml:873: exec returned: 2

Total time: 51 seconds

Upvotes: 0

Views: 2614

Answers (1)

Eric J.
Eric J.

Reputation: 150108

You have a path with a space in it, e.g.

c:\program files\java\jdk1.7.0_03\bin

You have to quote the path, like this:

"c:\program files\java\jdk1.7.0_03\bin"

Not 100% sure about Python, but this should work:

%systemroot%\system32;%systemroot%;%systemroot%\system32\wbem;%systemroot%\system32\windowspowershell\v1.0\;C:\Python27\;"c:\program files\java\jdk1.7.0_03\bin";.;c:\program files\tortoisesvn\bin;d:\apache-ant-1.8.3\bin;c:\program files\ibm\gsk8\lib;C:\PROGRA~1\IBM\SQLLIB\BIN;C:\PROGRA~1\IBM\SQLLIB\FUNCTION;C:\PROGRA~1\IBM\SQLLIB\SAMPLES\REPL;%M2_HOME%\bin;"C:\Program Files\Lenovo\Bluetooth Software\";

Notice that some of your path components are shortened to be 8.3 length compatible (they have a ~ in them). If you don't like the quoting or it doesn't work for Python, you can use the command

dir /x

to get the shortened version of each path component, e.g. on my system

06/12/2012  09:09 AM    <DIR>          PROGRA~1     Program Files
06/12/2012  09:08 AM    <DIR>          PROGRA~2     Program Files (x86)

Upvotes: 1

Related Questions