获取"进程fork失败"在运行ant run命令时

时间:2015-03-12 17:27:21

标签: java ant

在Ant中执行ant run命令时出现“Process fork failed”错误。请在下面找到build.xml文件。

<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE project []>

<project name="Learning TestNG" default="usage" basedir=".">  

<!-- ========== Initialize Properties =================================== -->
<property environment="env"/>

<property name="ws.home" value="${basedir}"/>
<property name="ws.jars" value="G:\Jars_libs"/>
<property name="test.dest" value="${ws.home}/build"/>
<property name="test.src" value="${ws.home}/src"/>
<property name="ng.result" value="G:\Java_Workspace\TestNG_XSLT_reports"/>

<!--target name="start-selenium-server">
    <java jar="${ws.home}/lib/selenium-server.jar"/>
</target-->

<target name="setClassPath" unless="test.classpath">
    <path id="classpath_jars">
        <fileset dir="${ws.jars}" includes="*.jar"/>
    </path>
    <pathconvert pathsep=":" 
        property="test.classpath" 
        refid="classpath_jars"/>
</target>

<target name="init" depends="setClassPath">
    <tstamp>
        <format property="start.time" pattern="MM/dd/yyyy hh:mm aa" />
    </tstamp>
    <condition property="ANT" 
        value="${env.ANT_HOME}/bin/ant.bat" 
        else="${env.ANT_HOME}/bin/ant">
                <os family="windows" />
    </condition>
    <taskdef name="testng" classpath="${test.classpath}"
           classname="org.testng.TestNGAntTask" />

</target>

<!-- all -->
<target name="all">
</target>

<!-- clean -->
<target name="clean">
    <delete dir="${test.dest}"/>
</target>

<!-- compile -->
<target name="compile" depends="init, clean" > 
    <delete includeemptydirs="true" quiet="true">
        <fileset dir="${test.dest}" includes="**/*"/>
    </delete>
    <echo message="making directory..."/>
    <mkdir dir="${test.dest}"/>
    <echo message="classpath------: ${test.classpath}"/>
    <echo message="compiling..."/>
    <javac 
        debug="true" 
        destdir="${test.dest}" 
        srcdir="${test.src}" 
        target="1.8" 
        classpath="${test.classpath}">

    </javac>
  </target>

<!-- build -->
<target name="build" depends="init">
</target>

<!-- run -->
<target name="run" depends="compile">
    <testng classpath="${test.classpath}:${test.dest}" suitename="My Suite">    
        <xmlfileset dir="${ws.home}" includes="testng.xml"/>
    </testng>
    <!--
    <testng classpath="${test.classpath}:${test.dest}" groups="fast">
        <classfileset dir="${test.dest}" includes="example1/*.class"/>
    </testng>
    -->
</target>

<target name="usage">
    <echo>
        ant run will execute the test
    </echo>
</target>

<path id="test.c">
        <fileset dir="${ws.jars}" includes="*.jar"/>
</path>

  <target name="makexsltreports">
        <mkdir dir="${ws.home}/XSLT_Reports/output"/>

        <xslt in="${ng.result}/testng-results.xml" style="src/xslt/testng-results.xsl"
              out="${ws.home}/XSLT_Reports/output/index.html" classpathref="test.c" processor="SaxonLiaison">
            <param name="testNgXslt.outputDir" expression="${ws.home}/XSLT_Reports/output/"/>
            <param name="testNgXslt.showRuntimeTotals" expression="true"/>
        </xslt>
    </target>

<!-- ****************** targets not used ****************** -->

在执行ant -verbose run命令时,我得到以下错误。我请求谦卑地帮助我,我已经搜索了所有内容,但一无所获。我在这方面陷入困境并且在最后4天尝试。 :(

  

java.io.IOException:无法运行程序“C:\ Program Files \ Java \ jre1.8.0_31 \ bin \ java.exe”:创建进程错误= 206,文件名或扩展名太长。

1 个答案:

答案 0 :(得分:4)

经过几个小时的吞噬,我能够解决这个问题。请从Classpath中删除不必要的jar文件并尝试。它对我有用。干杯..:)

REGS