build.xml: 38: Class not found: javac1.8

上一篇 / 下一篇  2015-07-30 17:30:52 / 个人分类:Eclipse

右击build.xml > Run As > Ant Build. 
遇到如下错误。 
build.xml: 38: Class not found: javac1.8。 
网上都说是ant版本太低,需要升级ant 版本。
我的Java版本是1.8, ant版本不能低于1.9。 

------------以下转自网络文章http://www.cxyclub.cn/n/44018/-----------------
升级ant的版本的方式是:
1.进入http://ant.apache.org/manualdownload.cgi下载新版本的Ant,下载之后解压。
2.进入你eclipse下的插件路径找出Ant插件,如我的就是D:\Android\eclipse\plugins\org.apache.ant_1.8.4.v201303080030,打开该路径,将Ant新版本解压出来的文件替换到该目录下,不过要保留META-INF目录 和plugin.properties文件。
3.可以通过cmd进入该插件的位置之后运行ant -version可以查看到ant的版本号,更新成功会显示新的版本号
4.重启eclipse,之后用ant打包就能正常兼容jdk1.8了。
---------------以上转自网络文章http://www.cxyclub.cn/n/44018/-----------------

这里我补充一下查看ant版本是需要进到插件的bin目录下。 在cmd下运行:
大多数情况下,这个时候在运行build.xml是不会在报错了。 

但是我还是报同样的错误。 于是又在网上找了其他方法。 
----------------------------以下转自网路文章http://stackoverflow.com/questions/23442621/ant-class-not-found-javac1-8#---------------
1>Set JAVA_HOME,JRE_HOME and Update Ant to 1.9
2>Over build.xml right click => run as (this takes into configuration)==>Now in this Edit Configuration and launch pop-up window
select Main tab then the third form. field called "Arguments" add:
-Dbuild.compiler=javac1.7
3> In build.xml add includeantruntime="false"
<javac srcdir="${src}" destdir="${bin}" debug="true" encoding="ISO-8859-1" includeantruntime="false">
        <classpath refid="my.classpath"/>
</javac>
----------------------------以上转自网路文章http://stackoverflow.com/questions/23442621/ant-class-not-found-javac1-8#---------------
这个时候编译就没有出错了。 

PS:如果还报错,再找其他办法。

TAG: Ant ant build javac XML xml

 

评分:0

我来说两句

Open Toolbar