我正在尝试利用 Ant 中的 Image 任务,这需要 Java Advanced Imaging。.jar 文件似乎在 Ant 库中,但是当我尝试缩放图像时,它给了我以下错误:
Could not load a dependent class javax/media/jai/PlanarImage
ant-jai.jar 文件没有这个类有什么原因吗?有没有人有在 Ant 中使用 JAI 的经验,或者特别是成功使用 Image 任务的经验?
谢谢!
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 元信息/ 元信息/清单.MF 组织/ 组织/阿帕奇/ 组织/阿帕奇/工具/ org/apache/工具/ant/ org/apache/tools/ant/taskdefs/ org/apache/tools/ant/taskdefs/可选/ org/apache/tools/ant/taskdefs/可选/图像/ org/apache/tools/ant/taskdefs/optional/image/Image.class org/apache/tools/ant/types/ org/apache/tools/ant/types/可选/ org/apache/tools/ant/types/可选/图像/ 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