JavaC CreateProcess error=206, The filename or extension is too long

风流意气都作罢 提交于 2019-12-11 14:18:03

问题


I tried to compile java code, but I got the error: Caused by: java.io.IOException: Cannot run program "C:\jdk\bin\javac": CreateProcess error=206, The filename or extension is too long.

This is the content of my build file:

 <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>

I think maybe my classpath: ${was_cp} is too long. How can I fix this ?


回答1:


The problem isn't that your classpath is too large. It's that you're converting into one gigantic string. Simply use the classpathref attribute instead:

<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"
/>


来源:https://stackoverflow.com/questions/48163497/javac-createprocess-error-206-the-filename-or-extension-is-too-long

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!