我正在做一些明顯錯誤的事情。我有一個簡單的小程序需要上傳文件到服務器。我寫了一個ant腳本來構建jar文件。然而,manifest.mf將類路徑分成多行。Java applet,將jar文件添加到清單文件
Manifest-Version: 1.0
Ant-Version: Apache Ant 1.7.0
Class-Path: lib/commons-codec-1.3.jar lib/commons-httpclien
t-3.1.jar lib/commons-logging-1.0.4.jar lib/plu
gin.jar
Created-By: 14.3-b01-101 (Apple Inc.)
我的build.xml文件是:
<project name="ScreenShot" default="dist" 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" />
<target name="init">
<!-- Create the time stamp -->
<tstamp />
<!-- Create the build directory structure used by compile -->
<mkdir dir="${build}" />
</target>
<target name="compile" depends="init" description="compile the source ">
<!-- Compile the java code from ${src} into ${build} -->
<javac srcdir="${src}" destdir="${build}">
<classpath>
<pathelement path="${classpath}" />
<pathelement path="lib/commons-codec-1.3.jar:lib/commons-httpclient-3.1.jar:lib/plugin.jar" />
</classpath>
</javac>
</target>
<target name="dist" depends="compile" description="generate the distribution">
<!-- Create the distribution directory -->
<mkdir dir="${dist}" />
<copy todir="${build}/lib">
<fileset dir="lib/" />
</copy>
<path id="libs.project">
<!-- lib.home contains all jar files, in several subdirectories -->
<fileset dir="lib">
<include name="**/*.jar" />
</fileset>
</path>
<manifestclasspath property="jar.classpath" maxParentLevels="1" jarfile="build/ScreenShot.jar">
<classpath refid="libs.project" />
</manifestclasspath>
<!-- Put everything in ${build} into the MyProject-${DSTAMP}.jar file -->
<jar jarfile="/Users/firemonk/red5/webapps/whiteboard/ScreenShot.jar" basedir="${build}">
<manifest>
<attribute name="Class-Path" value="${jar.classpath}" />
</manifest>
</jar>
</target>
<target name="clean" description="clean up">
<!-- Delete the ${build} and ${dist} directory trees -->
<delete dir="${build}" />
<delete dir="${dist}" />
</target>
</project>
我已經創建了一個測試項目和一個簡單的類(MyTest)和4個jar文件在lib文件夾中。 MyTest從每個jar文件實例化一個類來訪問所有的jar文件。 我想讓我的構建文件創建jar。 最後我用這個命令來測試: java命令ScreenShot.jar org.test.Delme 我總是找不到類錯誤 – firemonkey 2010-02-25 04:11:39
下載簡單的項目是鏈接: HTTP://文檔。 google.com/leaf?id=0B23I0Lzc_6noNTVmMDhmZDMtMDZlYi00ZmU4LWJkOTYtMDhkNzUyNmQxZGQ5&hl=zh-CN – firemonkey 2010-02-25 04:25:16
您可以請簡單的jar文件工作。我看不到我錯過了什麼。我花了2天時間。 – firemonkey 2010-02-25 04:29:35