javac 编译异常总结
1 error: package com.sun.image.codec.jpeg does not exist
使用Ant编译类时,当类中引用了com.sun.image.*下的类时会报错,找不到类
【解决办法】
将%JAVA_HOME%/jre/rt.jar拷贝到%ANT_HOME%/lib或其他文件夹,然后在javac时指定
eg:
<javac destdir="target/ROOT/WEB-INF/classes"
optimize="off"
debug="on"
failonerror="false"
srcdir="WEB-INF/src"
encoding="UTF-8"
excludes="**/*.smap">
<compilerarg value="-Xlint:unchecked"/>
<classpath>
<fileset dir="target/ROOT/WEB-INF/lib">
<include name="*.jar"/>
</fileset>
<fileset dir="${runtime-lib}">
<include name="*.jar"/>
</fileset>
</classpath>
<include name="**/*.java" />
</javac>
【注】${runtime-lib}中包含了rt.jar