Ant: Class not found: javac1.8

后端 未结 6 1239
刺人心
刺人心 2021-02-01 17:14

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         


        
相关标签:
6条回答
  • 2021-02-01 17:30

    I think, what you are seeing is Ant Bug 53347 (see https://issues.apache.org/bugzilla/show_bug.cgi?id=53347).

    If so, try either pf the following workarounds:

    Set the property "build.compiler" to a meaningful value like "javac1.7", or "javac1.3".

    Set the "compiler" attribute of the "javac" element of your build script to either of the above values. For all possible values, and their meaning, see http://ant.apache.org/manual/Tasks/javac.html

    0 讨论(0)
  • 2021-02-01 17:33

    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.

    0 讨论(0)
  • 2021-02-01 17:35

    I already did some extensive googling before asking this question but continuing that I found a solution here: This issue seems to only appear when using JDK 1.8 so using JDK 1.7 instead solves the problem. The following line needs to be added to eclipse.ini:

    -vm "path-to-jdk-1.7\bin\javaw.exe"
    
    0 讨论(0)
  • 2021-02-01 17:48

    To make it still more clear.

    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>
    

    Edit configuration

    It should compile without any message

    0 讨论(0)
  • 2021-02-01 17:50

    Mr. studro is right. I just confirmed an example on Ubuntu 14.04

    sudo apt-get install ant
    ant -version
    Apache Ant (TM) Version 1.9.3 compiled on April August 2014
    

    works perfectly in eclipse, just follow the steps described by Mr studro to configure the 'Ant Home' in eclipse with "/usr/share/ant".
    Regards, Stéphane.

    0 讨论(0)
  • 2021-02-01 17:52

    Make sure your source files are in "ProjectDirectory/src".

    0 讨论(0)
提交回复
热议问题