eclipse - 为什么 Eclipse 不能编译我的 java 1.5 代码?

标签 eclipse java java-5

我已经安装了 Eclipse 3.5.2 和 Java 6 的 JDK。

这是我在 Eclipse 中安装的 JRE

alt text http://img806.imageshack.us/img806/3345/eclipsejres.jpg

我正在尝试使用 ant 构建文件进行编译,其中一部分如下所示并指定 java 1.5:

<target name="compile" depends="build-common, init" description="Compile files. ">
    <javac srcdir="${src_dir}" destdir="${build_dir}" debug="true" target="1.5" source="1.5">
        <classpath path="${tomcat_home}/lib/servlet-api.jar;${tomcat_home}/lib/log4j-1.2.15.jar;/usr/local/lib/portlet-api-1.0.jar;." />
    </javac>
</target>

但是当我尝试编译时,控制台窗口显示以下错误:

compile:
    [javac] Compiling 1 source file to H:\jephperro\portlets\build
    [javac] javac: invalid target release: 1.5
    [javac] Usage: javac <options> <source files>
    [javac] where possible options include:
    [javac]   -g                        Generate all debugging info
    [javac]   -g:none                   Generate no debugging info
    [javac]   -g:{lines,vars,source}    Generate only some debugging info
    [javac]   -nowarn                   Generate no warnings
    [javac]   -verbose    ....

BUILD FAILED
H:\jephperro\portlets\CourseList-build.xml:25: Compile failed; see the compiler error output for details.

Total time: 531 milliseconds

我的 Eclipse 有什么问题吗?

最佳答案

see the compiler error output for details.

您可能依赖于使用比 1.5 JDK 更高版本的 Java 编译的库。

实际上,你的 1.5 JDK 在哪里?我看到的只是一个JRE。我的猜测是你只需要 download a version 1.5 JDK并将其添加到 Eclipse 中。

关于eclipse - 为什么 Eclipse 不能编译我的 java 1.5 代码?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3258784/

相关文章:

eclipse - 对没有上下文根的 Java 应用程序进行本地测试

java - apache tomcat问题-404错误

java - JFrame 中绘图的撤消按钮

java.lang.IllegalStateException 同时从基于另一个列表 <Double> Java 的列表中删除一个元素

java - RESTful @FormParam 400 错误请求

c - Eclipse:为所有新 C 项目选择默认调试器

java - ANTLR 4 : Missing Input Interpreter in eclipse ANTL4 plugin

java - JNI 将空参数传递给 Java 方法

java - 为什么jdk 1.5无法加载使用maven创建的jar? (版本号错误)

java - 在 java 1.5 中截断 Float(不包括 setRoundingMode)