Java 在ant构建文件中导入jar文件

Java 在ant构建文件中导入jar文件,java,ant,build,jar,Java,Ant,Build,Jar,我试图编译一个从jar导入类的项目,但它不起作用。这是我的主要课程: package sample.calendar; import org.jasypt.util.password.*; public class OutlookToGmailCalendarSync { public static void main(String[] args) { System.out.println("hi"); } } 以下是我的build.xml: <project name=

我试图编译一个从jar导入类的项目,但它不起作用。这是我的主要课程:

package sample.calendar;
import org.jasypt.util.password.*;
public class OutlookToGmailCalendarSync {
  public static void main(String[] args) {
    System.out.println("hi");
  }
}
以下是我的build.xml:

<project name="MyCalendarSample" default="run" basedir=".">
    <description>
        simple example build file
    </description>
  <!-- set global properties for this build -->
  <property name="src" location="src"/>
  <property name="build" location="build"/>
  <property name="dist"  location="dist"/>

  <path id="path.class">
    <pathelement location="build"/>
    <fileset dir="lib">
       <include name="*.jar"/>
    </fileset>
  </path>

  <!--Run-->
  <target name="run" depends="compile"
   description="Runs the complied project">
    <java fork="true" classname="sample.calendar.OutlookToGmailCalendarSync">
      <classpath>
        <path refid="path.class"/>
      </classpath>
    </java>
  </target>

  <!--Compile-->
  <target name="compile" depends="init"
        description="compile the source " >
    <!-- Compile the java code from ${src} into ${build} -->
    <javac srcdir="${src}" destdir="${build}"/>
  </target>

  <!--Init-->
  <target name="init">
    <!-- Create the time stamp -->
    <tstamp/>
    <mkdir dir="${build}"/>
  </target>

  <!--Clean-->
  <target name="clean"
        description="clean up" >
    <!-- Delete the ${build} directory trees -->
    <delete dir="${build}"/>
  </target>

</project>

org.jasypt.util.password位于lib文件夹中的jar文件中,为什么会出现此错误?

将的类路径设置为包含jasypt.jar

看起来“lib”中缺少jasypt.jar文件directoryI将compile部分中的行更改为
,但仍然得到相同的错误,即
package org.jasypt.util.password不存在
我将其更改为
classpathref
,而不是
classpath
,并且它现在正在工作,但是现在,当我尝试使用jar文件中的任何内容时,遇到了一个新问题。当我添加行
CalendarService myService=newcalendarservice(“korshyadoo-MyOutlookSync-0.1”)
对于main方法,我在线程“main”java.lang.NoClassDefFoundError:com/google/gdata/client/calendar/CalendarService中得到了
[java]异常。您的类路径需要包含您正在使用的库的所有jar,它们之间用冒号分隔。您的意思是在
下为每个jar文件添加一个include吗?*.jar不应该把它们都包括在内吗?
compile:
    [javac] C:\java\my\build.xml:31: warning: 'includeantruntime' was not set, d
efaulting to build.sysclasspath=last; set to false for repeatable builds
    [javac] Compiling 28 source files to C:\java\my\build
    [javac] C:\java\my\src\sample\calendar\OutlookToGmailCalendarSync.java:2: er
ror: package org.jasypt.util.password does not exist
    [javac] import org.jasypt.util.password.*;
    [javac] ^
    [javac] 1 error