File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Ant, Maven and Other Build Tools and the fly likes Execute failed: - error 2 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "Execute failed: - error 2" Watch "Execute failed: - error 2" New topic

Execute failed: - error 2

Afonso Alcantara

Joined: Nov 24, 2004
Posts: 1

I tried run an ant in my J2ME project, but i found this error:
BUILD FAILED: C:\des\crazy\java\build.xml:40: Execute failed: CreateProcess: preverify.exe -classpath C:\WTK21\lib\midpapi20.jar -d C:\des\crazy\java\bin\build\preverified C:\des\crazy\java\bin error=2

I am trying preverifies the code, but i don�t know what�s happen.

my target is:
<target name="preverify_SUN"
<mkdir dir="${}"/>
<exec dir="${SUN.bin.path}" (C:\WTK21\bin)
<arg line="-classpath ${SUN.midp20.path}"/> (C:\WTK21\lib\midpapi20.jar)
<arg line="-d ${}"/>
<arg line="${project.classes.dir}"/>

I verified the CLASSPATH, PATH, JAVA_HOME and others things, but I don�t find the error.

I am using the Eclipse to run and to edit the Ant.

Someone can help me?
[ November 24, 2004: Message edited by: Afonso Alcantara ]
Gem Cameron

Joined: Mar 21, 2006
Posts: 6

I have just had this same problem. You have to ensure the folder where this executable lives is included in your build path. You also need to explicitly define where the executable lives in your build file if it still doesn't work.

For instance my problem:
C:\workspace\WayneGrant\build.exe.xml:19: Execute failed: CreateProcess: makensis.exe error=2

From this line:
<exec executable="makensis.exe"/>

Was fixed by:
<project name="NSIS" default="build" basedir="." >

<target name="build" >

<property name="nsis.dir" value="c:/program files/nsis" />

<exec executable="${nsis.dir}/makensis.exe"/>



Although as you reported this problem a while ago you probably don't need this solution any more! lol

Roseanne Zhang
Ranch Hand

Joined: Nov 14, 2000
Posts: 1953
I had the problem before, I remember I needed to reinstall wtk somehow to make it work properly...

Also, I used antenna from sourceforge
Parameswaran Thangavel
Ranch Hand

Joined: Mar 01, 2005
Posts: 485
Hi Cameron

i too got the same error and fixed the erro by solution given by you.

<property name="nsis.dir" value="c:/program files/nsis" />
<exec executable="${nsis.dir}/makensis.exe"/>

if we need to give the full absolute path in the executable dir itself then what for the attribute dir exist for the task <exec>.

It will be more logical if we provide the dir as the path where exe file resides and executable will hold the exact file name..


<exec executable="makensis.exe" dir="c:/program files/nsis"/>

but the above script wont work? why???

Any one who knows please clarify me.
Binod Suman

Joined: May 07, 2008
Posts: 17

I have post to solve this problem in my blog.


Binod Suman
Martijn Verburg

Joined: Jun 24, 2003
Posts: 3275

Hi there,

Please DontWakeTheZombies, they bite!

Cheers, Martijn - Blog,
Twitter, PCGen, Ikasan, My The Well-Grounded Java Developer book!,
My start-up.
I agree. Here's the link:
subject: Execute failed: - error 2
It's not a secret anymore!