【问题标题】:eclipse Ant Build package does not existeclipse Ant Build 包不存在
【发布时间】:2019-01-29 20:49:01
【问题描述】:

我正在尝试在 Eclipse 中生成 .jar(以 Ant 构建方式运行),但我收到了关于我添加的 Apache jar 的类似错误:

[javac] *path...*: error: package org.apache.commons.io does not exist
[javac] import org.apache.commons.io.FilenameUtils;

罐子是从BuildPath->Add External Jar添加的。

我错过了任何一步吗?

【问题讨论】:

  • 不要再使用ant了。使用 maven 或 gradle
  • 您是否将这些 jar 依赖项添加到 Ant build.xml 中的路径中?
  • Ant build.xml 中未使用 Eclipse 构建路径

标签: java eclipse build jar eclipse-oxygen


【解决方案1】:

你需要在你的 build.xml 中配置编译路径 可以这样做

<path id="main.classpath">
  <fileset dir="<directory with your jar dependencies>">
     <include name="*.jar"/>
  </fileset>

然后将该路径的链接添加到您的javac 任务中

<javac destdir="<directory where to store class files>" srcdir="<directory with java files>" debug="on" compiler="modern">
     <classpath refid="main.classpath"/> <!-- this is where you tell javac which path to use -->
</javac>

【讨论】:

  • 感谢您的回答。现在我还有一个问题。情况是我正在使用 apache poi 并且我想包含 poi-ooxml.jar 并且如果我将其手动放入 build.xml 中,则编译后的 jar 不能像使用 poi-ooxml 那样工作(与 XSSFWorkbook 一起使用)。我怎样才能让它工作? poi.jar 不包含 XSSF。我很抱歉我的解释,我对此很菜鸟。谢谢!
  • 请使用您的 build.xml 和确切的错误消息提出新问题
猜你喜欢
  • 1970-01-01
  • 2017-04-18
  • 2010-12-20
  • 1970-01-01
  • 2012-01-31
  • 2021-01-29
  • 2017-08-30
  • 2013-06-01
  • 2018-05-06
相关资源
最近更新 更多