解决方法:
需要用到eclipse的jdt来编译class,不能再使用javac的默认编译方式。
在eclipse或MyEclipse的eclipse/plugin目录中找到org.eclipse.jdt.core_3.5.2.v_981_R35x.jar里面找到jdtCompilerAdapter.jar
还有
org.eclipse.jdt.compiler.tool_1.0.100.v_972_R35x.jar
org.eclipse.jdt.core_3.5.2.v_981_R35x.jar
org.eclipse.jdt.debug.ui_3.4.1.v20090811_r351.jar
jdtCompilerAdapter.jar
并拷贝到ant_home/lib下。
在ant的build.xml脚本中加入
或者
如果是用eclipse运行ant脚本,在右键菜单选择从RUN as Ant 启动build.xml时,在对话框中 选择Runtime jRE:run in the same JRE as workspace.
image
记得要引入上面需要的几个jar包