本文介绍了蚂蚁:类未找到:javac1.8的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想建立在Eclipse中使用Ant的项目。我右键点击build.xml文件>运行方式> Ant构建。不过,我收到以下错误:

 构建失败
C:\\用户\\大卫\\日食\\测试项目\\的build.xml:26:找不到课程:javac1.8

和还警告:

 编译:
[javac的] C:\\用户\\大卫\\日食\\测试项目\\的build.xml:26:警告:includeantruntime没有设置,默认为build.sysclasspath =最后;设置为false可重复的构建

正如我在其他职位看,这可能是由于有一只蚂蚁版本太旧或者没有正确这里设置环境变量是所有的信息:

  C:\\> Java的版本
Java版本1.8.0_05
的Java(TM)SE运行时环境(建立1.8.0_05-B13)
Java的热点(TM)64位服务器VM(25.5建造-B02,混合模式)C:\\>蚂蚁-version
Apache Ant的(TM)版本1.9.3于2013年12月23日编译C:\\>回声%JAVA_HOME%
C:\\ Program Files文件\\的Java \\ jdk1.8.0_05C:\\>回声%JRE_HOME%
C:\\ Program Files文件\\的Java \\ jre8

编辑:
这里是整个的build.xml,第26行是javac的标记:

 <?XML版本=1.0&GT?;
<,项目名称=试验项目默认为主BASEDIR =>
  &所述;! - 设置稍后可使用的变量。 - >
  <! - 一个属性的值是通过$ {}访问 - >
  <属性名=对于src.dir位置=SRC/>
  <属性名=build.dir位置=BIN/>
  <属性名=dist.dir位置=DIST/>
  <属性名=docs.dir位置=文档/>  <! - 删除现有的构建,文档和dist目录 - >
  <目标名称=干净>
    <删除DIR =$ {} build.dir/>
    <删除DIR =$ {} docs.dir/>
    <删除DIR =$ {} dist.dir/>
  < /目标与GT;  <! - 创建构建,文档和dist目录 - >
  <目标名称=MAKEDIR>
    < MKDIR DIR =$ {} build.dir/>
    < MKDIR DIR =$ {} docs.dir/>
    < MKDIR DIR =$ {} dist.dir/>
  < /目标与GT;  <! - 编译Java code(包括库为JUnit的使用 - >
  <目标名称=编译取决于=干净,MAKEDIR>
    < javac的SRCDIR =$ {}对于src.dirDESTDIR =$ {} build.dir>
    < / javac的>
  < /目标与GT;  <! - 创建的Javadoc - >
  <目标名称=文档依赖=编译>
    < javadoc的packagenames =SRC源路径=$ {}对于src.dirDESTDIR =$ {} docs.dir>
      <! - 定义哪些文件/目录应该得到包括在内,我们包括所有 - >
       <文件集DIR =$ {}对于src.dir>
                <包括姓名=**/>
           < /文件集>
    < / javadoc的>
  < /目标与GT;  <! - 创建部署JAR文件 - >
  <目标名称=罐子依赖=编译>
    <罐子destfile =$ {dist.dir} \\测试project1.jarBASEDIR =$ {} build.dir>
      <&舱单GT;
        <属性名=主类VALUE =test.Main/>
      < /清单>
    < /瓶>
  < /目标与GT;  <目标名称=主要依赖=编译,罐子,文件>
    <描述>主要目标和LT; /描述>
  < /目标与GT;< /项目>


解决方案

与您的Eclipse版本捆绑在一起的Ant版本是不是与Java兼容1.8

转到,并提取合适的地方的最新版本到你的文件系统。

在Eclipse中,转到窗口> preferences>蚂蚁>运行,点击 Ant主... 按钮,然后选择提取新下载蚂蚁的位置。

I am trying to build a project using Ant in eclipse. I right-clicked on build.xml > Run As > Ant Build. However, I am getting the following error:

BUILD FAILED
C:\Users\David\eclipse\test-project\build.xml:26: Class not found: javac1.8

and also a warning:

compile:
[javac] C:\Users\David\eclipse\test-project\build.xml:26: warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds

As I read in other posts that this might be due to having an ant version that is too old or not having set the environment variables correctly here is all the info:

C:\>java -version
java version "1.8.0_05"
Java(TM) SE Runtime Environment (build 1.8.0_05-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.5-b02, mixed mode)

C:\>ant -version
Apache Ant(TM) version 1.9.3 compiled on December 23 2013

C:\>echo %JAVA_HOME%
C:\Program Files\Java\jdk1.8.0_05

C:\>echo %JRE_HOME%
C:\Program Files\Java\jre8

EDIT:Here is the whole build.xml, line 26 is the javac tag:

<?xml version="1.0"?>
<project name="test-project" default="main" basedir=".">
  <!-- Sets variables which can later be used. -->
  <!-- The value of a property is accessed via ${} -->
  <property name="src.dir" location="src" />
  <property name="build.dir" location="bin" />
  <property name="dist.dir" location="dist" />
  <property name="docs.dir" location="docs" />

  <!-- Deletes the existing build, docs and dist directory-->
  <target name="clean">
    <delete dir="${build.dir}" />
    <delete dir="${docs.dir}" />
    <delete dir="${dist.dir}" />
  </target>

  <!-- Creates the  build, docs and dist directory-->
  <target name="makedir">
    <mkdir dir="${build.dir}" />
    <mkdir dir="${docs.dir}" />
    <mkdir dir="${dist.dir}" />
  </target>

  <!-- Compiles the java code (including the usage of library for JUnit -->
  <target name="compile" depends="clean, makedir">
    <javac srcdir="${src.dir}" destdir="${build.dir}">
    </javac>
  </target>

  <!-- Creates Javadoc -->
  <target name="docs" depends="compile">
    <javadoc packagenames="src" sourcepath="${src.dir}" destdir="${docs.dir}">
      <!-- Define which files / directory should get included, we include all -->
       <fileset dir="${src.dir}">
                <include name="**" />
           </fileset>
    </javadoc>
  </target>

  <!--Creates the deployable jar file  -->
  <target name="jar" depends="compile">
    <jar destfile="${dist.dir}\test-project1.jar" basedir="${build.dir}">
      <manifest>
        <attribute name="Main-Class" value="test.Main" />
      </manifest>
    </jar>
  </target>

  <target name="main" depends="compile, jar, docs">
    <description>Main target</description>
  </target>

</project>
解决方案

The version of Ant bundled with your version of Eclipse is not compatible with Java 1.8.

Go to the Ant download page, and extract the latest version somewhere appropriate onto your filesystem.

In Eclipse, go to Window > Preferences > Ant > Runtime, click the Ant Home... button, and select the location that you extracted the newly downloaded Ant to.

这篇关于蚂蚁:类未找到:javac1.8的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-15 06:27