在ant构建文件中导入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="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>

下面是我运行ant时的错误:

compile:
    [javac] C:javamybuild.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:javamybuild
    [javac] C:javamysrcsamplecalendarOutlookToGmailCalendarSync.java:2: er
ror: package org.jasypt.util.password does not exist
    [javac] import org.jasypt.util.password.*;
    [javac] ^
    [javac] 1 error

org.jasypt.util。password位于lib文件夹中的jar文件中,那么为什么我得到这个错误?

设置编译命令的类路径以包含jasypt.jar

相关内容

  • 没有找到相关文章

最新更新