我尝试编译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}太长了。我怎样才能解决这个问题 ?
答案 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"
/>