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

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

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。

  1. javac -version
  2. javac 1.8.0_91
  3. java -version
  4. java version "1.8.0_91"
  5. Java(TM) SE Runtime Environment (build 1.8.0_91-b14)
  6. Java HotSpot(TM) 64-Bit Server VM (build 25.91-b14, mixed mode)
  7. ant -v
  8. Apache Ant 版本 1.7.1,编译于 2010 4 26

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

  1. ant
  2. Buildfile: build.xml
  3. compileBuildDir:
  4. [javac] 正在将 12 个源文件编译到 /build
  5. [javac] Model.java:19: 无法访问 DBObject
  6. [javac] 错误的类文件: Utilities.jar(DBObject.class)]
  7. [javac] 类文件版本错误 52.0,应为 50.0
  8. [javac] 请删除或确保它出现在类路径的正确子目录中。
  9. [javac] import DBObject;
  10. [javac]
  11. BUILD FAILED
  12. /build.xml:173: 编译失败;有关详细信息,请查看编译器错误输出。

当我执行 ant -v 时:

  1. ant -v
  2. Apache Ant 版本 1.7.1,编译于 2010 4 26
  3. Buildfile: build.xml
  4. 检测到的 Java 版本:1.6,位于:/usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0.x86_64/jre
  5. 检测到的操作系统:Linux
  6. 正在解析 buildfile /build.xmlURI = file:/test/build.xml
  7. 项目基目录设置为:/myProject
  8. [antlib:org.apache.tools.ant] 无法从资源 org/apache/tools/ant/antlib.xml 加载定义。找不到该文件。
  9. 目标(packageApplication) 的构建顺序为 [compileBuildDir, packageApplication]
  10. 完整的构建顺序为 [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.

  1. javac -version
  2. javac 1.8.0_91
  3. java -version
  4. java version "1.8.0_91"
  5. Java(TM) SE Runtime Environment (build 1.8.0_91-b14)
  6. Java HotSpot(TM) 64-Bit Server VM (build 25.91-b14, mixed mode)
  7. ant -v
  8. 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?

  1. ant
  2. Buildfile: build.xml
  3. compileBuildDir:
  4. [javac] Compiling 12 source files to /build
  5. [javac] Model.java:19: cannot access DBObject
  6. [javac] bad class file: Utilities.jar(DBObject.class)]
  7. [javac] class file has wrong version 52.0, should be 50.0
  8. [javac] Please remove or make sure it appears in the correct subdirectory of the classpath.
  9. [javac] import DBObject;
  10. [javac]
  11. BUILD FAILED
  12. /build.xml:173: Compile failed; see the compiler error output for details.

When I do a ant -v

  1. ant -v
  2. Apache Ant version 1.7.1 compiled on April 26 2010
  3. Buildfile: build.xml
  4. Detected Java version: 1.6 in: /usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0.x86_64/jre
  5. Detected OS: Linux
  6. parsing buildfile /build.xml with URI = file:/test/build.xml
  7. Project base dir set to: /myProject
  8. [antlib:org.apache.tools.ant] Could not load definitions from resource org/apache/tools/ant/antlib.xml. It could not be found.
  9. Build sequence for target(s) `packageApplication' is [compileBuildDir, packageApplication]
  10. 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:

确定