使用ANT编译项目报错 com.sun.image.codec.jpeg does not exist 解决方法

简介:

项目开发中在对图片进行裁切处理的时候,有时候是会使用到 com.sun 包下的类时,

如果项目使用ant编译,会出现错误 com.sun.image.codec.jpeg does not exist 这是因为在JDK1.7+时,Oracle不允许使用sun.*的jar


具体参见http://www.oracle.com/technetwork/java/faq-sun-packages-142232.html 。



项目代码已经写好,且直接运行可以正常使用,只是使用ant编译会出现错误,现在不打算更换项目的具体实现代码,不能更换JDK版本,所以做如下处理即可:

在ANT中明确指定使用这个rt.jar ,如下:

	<!-- 使用ant编译,在使用到com.sun包下类时,需要指定rt.jar文件的位置 -->
<path id="JAVA.rt">
		<pathelement location="${frameone.runtime}/common/rt.jar" />
	</path>
 

	<path id="Project.classpath">
		<path refid="JAVA.rt" />
		<fileset dir="${project.lib.dir}" includes="*.jar" />
	</path>

	<target name="build-project" depends="init">
		<echo message="${ant.project.name}: ${ant.file}" />
		<javac includeantruntime="false" debug="true" debuglevel="${debuglevel}" destdir="${dist.classes.dir.cms}" source="${source}" target="${target}" encoding="UTF-8">
			<src path="${src.dir}" />
			<classpath refid="Project.classpath" />
		</javac>
	</target>


其实上面的方法,可能会不起作用,我们可以指定javac 参数来忽略这样的错误,如下:

<javac includeantruntime="false" debug="true" debuglevel="${debuglevel}" destdir="${build.dir}/WEB-INF/classes" source="${source}" target="${target}" encoding="UTF-8">
<src path="${src.dir}" />   
<compilerarg line="-XDignore.symbol.file"/>
<classpath refid="Project.classpath" />
</javac>




目录
相关文章
|
4月前
|
存储 Java
Java【报错 01】Unable to open nested jar file 问题说明及解决方法(仅针对压缩工具 WinRAR)
Java【报错 01】Unable to open nested jar file 问题说明及解决方法(仅针对压缩工具 WinRAR)
141 0
|
计算机视觉
OpenCV编译时提示错误“ Built target libprotobuf”
OpenCV编译时提示错误“ Built target libprotobuf”
409 0
|
开发工具 Android开发
eclipse Unable to build: the file dx.jar was not loaded from the SDK folder的解决办法
eclipse Unable to build: the file dx.jar was not loaded from the SDK folder的解决办法
87 0
|
Java Maven Android开发
Missing artifact com.sun tools.jar 1.5.0 system 解决方法
Missing artifact com.sun tools.jar 1.5.0 system 解决方法
158 0
Keil报错:cannot open source input file "core_cmInstr.h" 解决办法
Keil报错:cannot open source input file "core_cmInstr.h" 解决办法
409 0
Keil报错:cannot open source input file "core_cmInstr.h" 解决办法
|
程序员 iOS开发 开发者
iOS开发:程序打包提示Ignoring file XXX missing required architecture arm7 in file XXX错误
前段时间在开发过程中遇到一个iOS打包报错Ignoring file XXX missing required architecture arm7 in file XXX的问题,然后回想了一下问题所在,是因为集成了ijk播放器插件,然后ijk三方库不支持arm7造成的报错。
142 0
iOS开发:程序打包提示Ignoring file XXX missing required architecture arm7 in file XXX错误
关于 海思平台sample的demo中添加ffmpeg静态库(.a)报错误undefined reference toavpriv_pix_fmt_hps_avi等错误 的解决方法
关于 海思平台sample的demo中添加ffmpeg静态库(.a)报错误undefined reference toavpriv_pix_fmt_hps_avi等错误 的解决方法
关于 海思平台sample的demo中添加ffmpeg静态库(.a)报错误undefined reference toavpriv_pix_fmt_hps_avi等错误 的解决方法
|
Android开发
解决bug:在eclipse中导入Android项目时报错: “invalid resource directory name bin/res/crunch”
解决bug:在eclipse中导入Android项目时报错: “invalid resource directory name bin/res/crunch”
442 0
|
Python
Python 常见问题 - 使用 poetry build 打包构建失败,报 ModuleOrPackageNotFound No file/folder found for package filesystemfastapi
Python 常见问题 - 使用 poetry build 打包构建失败,报 ModuleOrPackageNotFound No file/folder found for package filesystemfastapi
274 0
Python 常见问题 - 使用 poetry build 打包构建失败,报 ModuleOrPackageNotFound No file/folder found for package filesystemfastapi
|
Java Android开发
【错误记录】Android Studio 配置 AspectJ 报错 ( Failed to create Jar file C:\xxx\aspectjtools-1.8.10.jar. )
【错误记录】Android Studio 配置 AspectJ 报错 ( Failed to create Jar file C:\xxx\aspectjtools-1.8.10.jar. )
700 0
【错误记录】Android Studio 配置 AspectJ 报错 ( Failed to create Jar file C:\xxx\aspectjtools-1.8.10.jar. )