让Image任务在Ant中工作

时间:2011-06-17 04:00:01

标签: java ant jai

我正在尝试使用Ant中的Image任务,这需要Java Advanced Imaging。 .jar文件似乎在Ant库中,但是当我尝试缩放图像时,它会给我以下错误:

Could not load a dependent class javax/media/jai/PlanarImage

为什么ant-jai.jar文件已经没有这个类了?有没有人有使用Ant中的JAI,或者特别是成功使用Image任务的经验?

谢谢!

1 个答案:

答案 0 :(得分:1)

JAR仅包含Image task中定义的对象。你也必须把JAI放在你的课程路径上。

附录:关于NoClassDefFoundError: javax.media.jai.OperationRegistrySpi,您可以验证该课程是否在jai_core.jar,如下所示。追踪此类异常的一种方法是使用-verbose命令的java选项。

$ jar tf jai_core.jar | grep OperationRegistrySpi
javax/media/jai/OperationRegistrySpi.class

$ jar tf lib/ant-jai.jar 
META-INF/
META-INF/MANIFEST.MF
org/
org/apache/
org/apache/tools/
org/apache/tools/ant/
org/apache/tools/ant/taskdefs/
org/apache/tools/ant/taskdefs/optional/
org/apache/tools/ant/taskdefs/optional/image/
org/apache/tools/ant/taskdefs/optional/image/Image.class
org/apache/tools/ant/types/
org/apache/tools/ant/types/optional/
org/apache/tools/ant/types/optional/image/
org/apache/tools/ant/types/optional/image/Arc.class
org/apache/tools/ant/types/optional/image/BasicShape.class
org/apache/tools/ant/types/optional/image/ColorMapper.class
org/apache/tools/ant/types/optional/image/Draw.class
org/apache/tools/ant/types/optional/image/DrawOperation.class
org/apache/tools/ant/types/optional/image/Ellipse.class
org/apache/tools/ant/types/optional/image/ImageOperation.class
org/apache/tools/ant/types/optional/image/Rectangle.class
org/apache/tools/ant/types/optional/image/Rotate.class
org/apache/tools/ant/types/optional/image/Scale$ProportionsAttribute.class
org/apache/tools/ant/types/optional/image/Scale.class
org/apache/tools/ant/types/optional/image/Text.class
org/apache/tools/ant/types/optional/image/TransformOperation.class