javac1.8 class not found

Viewed 102414

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

<target name="compileCustomSrc">
    <javac srcdir="src" destdir="build/classes" source="1.5" target="1.5" >
        <classpath>
            <fileset dir="C:/lib/">
                <include name="*.jar" />
            </fileset>
        </classpath>
    </javac>
</target>

Before installing jdk1.8, Ant invoked from Eclipse compiled all sources successful. But now, I have following error message:

Class not found: javac1.8

My JAVA_HOME and JRE_HOME:

JAVA_HOME = C:\Program Files (x86)\Java\jdk1.5.0_16
JRE_HOME = C:\Program Files (x86)\Java\jre1.5.0_16

and set in Eclipse JRE to 1.5. Does Java 1.8 set some configs during installation?

13 Answers

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

  1. Right click on the ant task name, e.g. `myBuild.xml in the ant window.

  2. Choose Run As | External Tool Configurations.

  3. Then on the JRE tab, choose Separate JRE: Java JDK7 or whatever your java 7 is named.

  4. Hit Apply and then Run.

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

Sometimes the issue while building the war through ANT is also related to java version miss match in build.properties files as build.XML tries to use the java version mentioned in build.compiler property

check whether build.compiler property is same as intended java version.

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.

I had the same problem. And I was able to solve it within the build.xml by setting a property.

<property "build.compiler=javac1.7">
Related