Ant:找不到类:javac1.8 [英] Ant: Class not found: javac1.8

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

问题描述

我正在尝试在 Eclipse 中使用 Ant 构建一个项目.我右键单击 build.xml > Run As > Ant Build.但是,我收到以下错误:

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

还有一个警告:

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

正如我在其他帖子中读到的,这可能是由于 ant 版本太旧或没有正确设置环境变量,这里是所有信息:

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

这是整个build.xml,第26行是javac标签:

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> 

推荐答案

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

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

转到 Ant 下载页面,然后将最新版本解压缩到文件系统的适当位置.

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

在 Eclipse 中,转到 Window >首选项蚂蚁>运行时,点击Ant Home...按钮,选择你解压新下载的Ant的位置.

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.

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

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆