JavaC CreateProcess error = 206,文件名或扩展名太长

时间:2018-01-09 07:47:15

标签: java jenkins ant javac

我尝试编译java代码,但是我收到了错误: 引起:java.io.IOException:无法运行程序" C:\ jdk \ bin \ javac":CreateProcess error = 206,文件名或扩展名太长。

这是我的构建文件的内容:

 <path id="was.runtime">
            <!-- <fileset dir="C:\Users\Administrator\.jenkins\workspace\BUILD2TEST\BUILD2TEST\WebContent\WEB-INF\lib">
                <include name="*.jar"/>
              </fileset> -->          
             <fileset dir="${copy.from.path}/WebContent/WEB-INF/lib">
                <include name="*.jar" />
            </fileset> 
            <fileset dir="${was_home}/lib">
                <include name="**/*.jar" />
            </fileset>
            <fileset dir="${was_home}/plugins">
                <include name="**/*.jar" />
            </fileset>

      </path>
        <property name="was_cp" value="${toString:was.runtime}" />


<javac fork="yes" executable="${java.home}/bin/javac" compiler="javac1.6" includeantruntime="false" encoding="utf-8" srcdir="${workspace}/${project.name}/src" destdir="${workspace}/${project.name}/WebContent/WEB-INF/classes" classpath="${was_cp}">
                </javac>

我想也许是我的类路径:$ {was_cp}太长了。我怎样才能解决这个问题 ?

1 个答案:

答案 0 :(得分:1)

问题不在于classpath太大了。你正在转换成一个巨大的字符串。只需使用classpathref属性:

<path id="was.runtime">        
    <fileset dir="${copy.from.path}/WebContent/WEB-INF/lib">
        <include name="*.jar" />
    </fileset> 
    <fileset dir="${was_home}/lib">
        <include name="**/*.jar" />
    </fileset>
    <fileset dir="${was_home}/plugins">
        <include name="**/*.jar" />
    </fileset>
</path>

<javac
    fork="yes"
    executable="${java.home}/bin/javac"
    compiler="javac1.6"
    includeantruntime="false"
    encoding="utf-8"
    srcdir="${workspace}/${project.name}/src"
    destdir="${workspace}/${project.name}/WebContent/WEB-INF/classes"
    classpathref="was.runtime"
/>