Build.xml给出问题..“CreateProcess error = 87,参数不正确”

时间:2012-03-23 05:39:34

标签: windows ant build.xml

我试图在Windows环境中使用ant build脚本执行我的java程序。

但是我得到了以下问题。这是在linux环境下工作。

    [1] init:

    compile:

    stockquote:
         [java] C:\wso2esb-4.0.0-SNAPSHOT\samples\axis2Client\build.xml:128: java.io.IOException: Cannot run program "C:\Program Files\Java\jdk1.6.0_20\jr
    e\bin\java.exe": CreateProcess error=87, The parameter is incorrect
         [java]     at org.apache.tools.ant.taskdefs.Java.fork(Java.java:798)
         [java]     at org.apache.tools.ant.taskdefs.Java.executeJava(Java.java:214)
         [java]     at org.apache.tools.ant.taskdefs.Java.executeJava(Java.java:135)
         [java]     at org.apache.tools.ant.taskdefs.Java.execute(Java.java:108)
         [java]     at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
         [java]     at sun.reflect.GeneratedMethodAccessor6.invoke(Unknown Source)
         [java]     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         [java]     at java.lang.reflect.Method.invoke(Method.java:597)
         [java]     at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
         [java]     at org.apache.tools.ant.Task.perform(Task.java:348)
         [java]     at org.apache.tools.ant.Target.execute(Target.java:390)
         [java]     at org.apache.tools.ant.Target.performTasks(Target.java:411)
         [java]     at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1399)
         [java]     at org.apache.tools.ant.Project.executeTarget(Project.java:1368)
         [java]     at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
         [java]     at org.apache.tools.ant.Project.executeTargets(Project.java:1251)
         [java]     at org.apache.tools.ant.Main.runBuild(Main.java:809)
         [java]     at org.apache.tools.ant.Main.startAnt(Main.java:217)
         [java]     at org.apache.tools.ant.launch.Launcher.run(Launcher.java:280)
         [java]     at org.apache.tools.ant.launch.Launcher.main(Launcher.java:109)
         [java] Caused by: java.io.IOException: Cannot run program "C:\Program Files\Java\jdk1.6.0_20\jre\bin\java.exe": CreateProcess error=87, The parameter is incorrect
         [java]     at java.lang.ProcessBuilder.start(ProcessBuilder.java:460)
         [java]     at java.lang.Runtime.exec(Runtime.java:593)
         [java]     at org.apache.tools.ant.taskdefs.Execute$Java13CommandLauncher.exec(Execute.java:862)

 
   <target name="stockquote" depends="compile">
            <java classname="samples.userguide.StockQuoteClient"
                  classpathref="javac.classpath" fork="true">
                <sysproperty key="symbol" value="${symbol}"/>
                <sysproperty key="mode"   value="${mode}"/>
                <sysproperty key="addurl" value="${addurl}"/>
                -----------------------------------------------

<target name="init">
        <mkdir dir="${class.dir}"/>
        <mkdir dir="./../../work/temp/sampleClient"/>
        <path id="javac.classpath">
            <pathelement path="${class.dir}"/>
            <pathelement path="../../lib"/>
            <fileset dir="../../repository/components/plugins">              
                <include name="*.jar"/>              
            </fileset>

            <fileset dir="../../lib">
                <include name="*.jar"/>
            </fileset>
            <fileset dir="../../lib/endorsed">
                <include name="*.jar"/>
            </fileset>
            <fileset dir="../../repository/components/extensions">
                <include name="*.jar"/>
            </fileset>
            <fileset dir="../../repository/components/lib">
                <include name="*.jar"/>
            </fileset>
        </path>
    </target>

1 个答案:

答案 0 :(得分:7)

看起来你的CLASSPATH太长了,Windows无法应付。

Google for“CreateProcess error = 87,参数不正确”。另请参阅此answer

您需要缩短类路径。尽量只包括StockQuoteClient的实际依赖项,而不是所有其他“* .jar”条目。