java - 在 linux 上使用 ant 编译时出错:错误的版本 52.0,应该是 50.0
问题描述
在我使用 eclipse ant 和 java 1.8 在 Windows 上编译我的代码之前,它可以正常工作。
现在我在 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 version 1.7.1 compiled on April 26 2010
但是,当我运行 ant 来启动我的 build.xml 时,它仍然因 javac 错误而失败。还有什么我需要设置的吗?
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.
当我做一个 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, ]
解决方案
检测到的 Java 版本:1.6 在:/usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0.x86_64/jre
这是您的答案 - 您的路径设置不正确。
看看这里:
推荐阅读
- python - 用什么代替 BREAK ( PYTHON )
- spring-boot - th:每个数据表在 Bootstrap 4 中不起作用
- google-cloud-functions - 在 Google Cloud Storage 中创建基于日期的文件夹
- java - 如何设置对象的状态
- android - Kotlin + MockIto + Android Instrumentation 测试
- amazon-s3 - 如何将 s3 存储桶中的文本文件访问到 sagemaker 以训练模型?
- python - 通过 Python 发送电子邮件时出错
- mysql - Mysql 数据库表崩溃的 Wordpress (Ubuntu)
- c# - 被调用函数内部的参数值不同
- javascript - MongooseError [CastError]:模型“用户”的路径值转换为字符串失败