Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
398 views
in Technique[技术] by (71.8m points)

java - javac1.8 class not found

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)Javajdk1.5.0_16
JRE_HOME = C:Program Files (x86)Javajre1.5.0_16

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...