我试图在windows环境中使用ant构建脚本执行我的java程序。
但我有以下问题。这是在linux环境中工作的。
[1] 初始化:编译:股票报价:[java]C:\wso2esb-4.0.0-SNAPSHOT\samples\axis2Client\build.xml:128:java.io.io异常:无法运行程序"C:\program Files\java\jdk1.6.0_20\jre\bin\java.exe":CreateProcess错误=87,参数不正确[java]在org.apache.tools.ant.taskdefs.java.fork(java.java:798)[java]在org.apache.tools.ant.taskdefs.java.executeJava(java.java:214)[java]在org.apache.tools.ant.taskdefs.java.executeJava(java.java:135)[java]在org.apache.tools.ant.taskdefs.java.execure(java.java:108)[java]在org.apache.tools.ant.UnnknownElement.exexecute(UnknownElement.java:291)[java]位于sun.reflect.GeneratedMethodAccessor6.invoke(未知源)[java]在sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)[java]位于java.lang.reflect.Method.ioke(Method.java:597)[java]在org.apache.tools.ant.dispatch.Utils.execute(DispatchUtils.java:106)[java],网址:org.apache.tools.ant.Task.aperform(Task.java:348)[java]位于org.apache.tools.ant.Target.execute(Target.java:390)[java],网址:org.apache.tools.ant.Target.performTasks(Target.java:411)[java],网址:org.apache.tools.ant.Project.executeSortedTargets(Project.java:1399)[java]在org.apache.tools.ant.Project.executeTarget(Project.java:1368)[java],网址为org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)[java]在org.apache.tools.ant.Project.executeTargets(Project.java:1251)[java]位于org.apache.tools.ant.Main.runBuild(Main.java:809)[java]在org.apache.tools.ant.Main.startAnt(Main.java:217)[java]在org.apache.tools.ant.slaunch.Launcher.run(Launcher.java:280)[java]在org.apache.tools.ant.slaunch.Launcher.main(Launcher.java:109)[java]原因:java.io.io异常:无法运行程序"C:\program Files\java\jdk1.6.0_20\jre\bin\java.exe":CreateProcess错误=87,参数不正确[java],位于java.lang.ProcessBuilder.start(ProcessBuilder.java:460)[java],位于java.lang.Runtime.exec(Runtime.java:593)[java]在org.apache.tools.ant.taskdefs.Execute$Java13CommonLauncher.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>
您的CLASSPATH太长,Windows无法处理。
谷歌搜索"CreateProcess错误=87,参数不正确"。另请参阅此答案。
您需要缩短类路径。尽量只包括StockQuoteClient的实际依赖项,而不包括其他内容,而不是所有的"*.jar"条目。