eclipse Ant Build软件包不存在

时间:2018-08-23 12:56:41

标签: java eclipse build jar eclipse-oxygen

我试图在eclipse中生成一个.jar(以Ant Build的身份运行),但是我收到类似这样的关于我添加的Apache jar的错误:

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

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

我错过了任何一步吗?

1 个答案:

答案 0 :(得分: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>