2

我正在尝试编译一个从 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:\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

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

4

1 回答 1

3

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

于 2013-03-31T16:19:50.143 回答