错误:在Linux上使用ant编译时出错:版本错误 52.0,应为 50.0。

huangapple go评论75阅读模式
英文:

error compiling using ant on linux: wrong version 52.0, should be 50.0

问题

以下是翻译好的内容:

在 Windows 上,我使用 Eclipse、Ant 和 Java 1.8 编译我的代码,它完全正常运行。

现在我在 Linux 上进行编译。
我确保下载了 JDK 1.8 和 Ant。

javac -version
javac 1.8.0_91

java -version
java version "1.8.0_91"
Java(TM) SE Runtime Environment (build 1.8.0_91-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.91-b14, mixed mode)

ant -v
Apache Ant 版本 1.7.1,编译于 2010 年 4 月 26 日

然而,当我运行 ant 启动我的 build.xml 时,仍然失败,似乎是 javac 出了问题。我是否需要设置其他内容?

ant
Buildfile: build.xml

compileBuildDir:
    [javac] 正在将 12 个源文件编译到 /build
    [javac] Model.java:19: 无法访问 DBObject
    [javac] 错误的类文件: Utilities.jar(DBObject.class)]
    [javac] 类文件版本错误 52.0,应为 50.0
    [javac] 请删除或确保它出现在类路径的正确子目录中。
    [javac] import DBObject;
    [javac]                     

BUILD FAILED
/build.xml:173: 编译失败;有关详细信息,请查看编译器错误输出。

当我执行 ant -v 时:

ant -v
Apache Ant 版本 1.7.1,编译于 2010 年 4 月 26 日
Buildfile: build.xml
检测到的 Java 版本:1.6,位于:/usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0.x86_64/jre
检测到的操作系统:Linux
正在解析 buildfile /build.xml,URI = file:/test/build.xml
项目基目录设置为:/myProject
[antlib:org.apache.tools.ant] 无法从资源 org/apache/tools/ant/antlib.xml 加载定义。找不到该文件。
目标(packageApplication) 的构建顺序为 [compileBuildDir, packageApplication]
完整的构建顺序为 [compileBuildDir, packageApplication, reports, cleanTmpDir, copyToTmp, copyToTmpplot, ]
英文:

Before I compiled my code on Windows using eclipse ant and java 1.8 and it was fully working.

Now I am using compiling on Linux.
I made sure to download jdk 1.8 and ant.

javac -version
javac 1.8.0_91

java -version
java version "1.8.0_91"
Java(TM) SE Runtime Environment (build 1.8.0_91-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.91-b14, mixed mode)

ant -v
Apache Ant version 1.7.1 compiled on April 26 2010

However, when I run ant to launch my build.xml, it is still failing from what seems to be wrong javac. Is there something else I need to set?

 ant
Buildfile: build.xml

compileBuildDir:
    [javac] Compiling 12 source files to /build
    [javac] Model.java:19: cannot access DBObject
    [javac] bad class file: Utilities.jar(DBObject.class)]
    [javac] class file has wrong version 52.0, should be 50.0
    [javac] Please remove or make sure it appears in the correct subdirectory of the classpath.
    [javac] import DBObject;
    [javac]                     

BUILD FAILED
/build.xml:173: Compile failed; see the compiler error output for details.

When I do a ant -v

ant -v
Apache Ant version 1.7.1 compiled on April 26 2010
Buildfile: build.xml
Detected Java version: 1.6 in: /usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0.x86_64/jre
Detected OS: Linux
parsing buildfile /build.xml with URI = file:/test/build.xml
Project base dir set to: /myProject
[antlib:org.apache.tools.ant] Could not load definitions from resource org/apache/tools/ant/antlib.xml. It could not be found.
Build sequence for target(s) `packageApplication' is [compileBuildDir, packageApplication]
Complete build sequence is [compileBuildDir, packageApplication, reports, cleanTmpDir, copyToTmp, copyToTmpplot, ]

答案1

得分: 1

Detected Java version: 1.6 in: /usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0.x86_64/jre

This is your answer - your path setup is not correct.

Look at this here:

https://stackoverflow.com/questions/28180915/class-file-has-wrong-version-52-0-should-be-50-0

英文:

Detected Java version: 1.6 in: /usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0.x86_64/jre

This is your answer - your path setup is not correct.

Look at this here:

https://stackoverflow.com/questions/28180915/class-file-has-wrong-version-52-0-should-be-50-0

huangapple
  • 本文由 发表于 2020年4月11日 03:45:09
  • 转载请务必保留本文链接:https://go.coder-hub.com/61147604.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定