我试图编译java代码,但我得到错误:原因:java.io.IOException:无法运行程序"C:\jdk\bin\javac":CreateProcess 错误 = 206,文件名或扩展名太长。
这是我的构建文件的内容:
<path id="was.runtime">
<!-- <fileset dir="C:UsersAdministrator.jenkinsworkspaceBUILD2TESTBUILD2TESTWebContentWEB-INFlib">
<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} 太长了。我该如何解决这个问题?
问题不在于你的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"
/>