javac1.8 class not found

后端 未结 12 1767
予麋鹿
予麋鹿 2020-11-27 13:10

I have installed two jdks - jdk 1.5 and jdk 1.8. I have following Ant build.xml config file :


    

        
相关标签:
12条回答
  • 2020-11-27 13:37
    Class not found: javac1.8

    This error is known to happen with Apache Ant versions less than 1.9.0 - which aren't compatible with Java 8. If you're using a version of Ant < 1.9.0, you should update to a 1.9.x release.

    Here is the related bug report: https://issues.apache.org/bugzilla/show_bug.cgi?id=53347

    Btw, if you just want to compile with Java 8, but don't need to compile any actual Java 8 syntax, then you can pass the following argument to javac as a workaround, which would allow you to continue using an older version of Ant:

    -Dbuild.compiler=javac1.7
    
    0 讨论(0)
  • 2020-11-27 13:40

    You can download a newer version of eclipse, which includes a newer version of Ant in the plugins directory. Then, copy the Ant jar into the older eclipse's plugin directory. Eclipse will automatically point to the newer version of Ant. This worked for older Kepler with newer Mars2 for me.

    0 讨论(0)
  • 2020-11-27 13:43

    Update Ant to 1.9.x release as Java 8 in incompatible with Ant versions less tha 1.9 or after the comand put -Dbuild.compiler=javac1.7, see the below:

    ant release -Dbuild.compiler=javac1.7

    0 讨论(0)
  • 2020-11-27 13:44

    Update Ant to 1.9.x release as Java 8 in incompatible with Ant versions less tha 1.9

    0 讨论(0)
  • 2020-11-27 13:45

    I tried all of the other solutions, but none worked. I finally found an approach that worked for me in Eclipse:

    • Right click on the ant task name, e.g. "compileCustomSrc" in the ant window.
    • Choose Run As | External Tool Configurations
    • Then on the JRE tab, choose Separate JRE: Java SE7 or whatever your java 7 is named, then hit Apply and then Run.

    Your ant task will be executed, and will build correctly!

    0 讨论(0)
  • 2020-11-27 13:49

    I had this same issue. I had JAVA_HOME and JRE_HOME set correctly. I also had Ant > 1.9.

    What I did to fix it is go into Eclipse to Window -> Preferences. Expand Ant and select Runtime. By default the Classpath tab should be selected and on the right hand side there is a button called "Ant Home". Click this button and double check it is pointed to your Ant folder.

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