Java jar – JAVA編程語言程序開發技術文章

In CMD, we can use the JDK's command: jar.

1. To pack two .class files into an archive named testPackage.jar

jar cvf testPackage.jar classFile1.class classFile2.class

2. To pack two .class files into an archive named testPackage2.jar with the usage of a existant manifest file "manifestForTest"
jar cvfm testPackage2.jar manifestForTest classFile1.class classFile2.class

3. To pack all the .class files in a folder specified into an archive named testPackage3.jar with the usage of a existant manifest file "manifestForTest"

jar cvfm testPackage3.jar manifestForTest -C folderPath

 

1. 清單文件manifest,對www.aiwalls.com格式要求很高,註意每個冒號後面要有一個空格,文件最後要有一個空行。

2. 對於引用到外部jar包的工程,需要在manifeste中定義好Class-Path屬性。

 

In Eclipse, you can use the related GUI guide for creating .jar file.

 

For executing .jar files, you have only to use the command: java -jar jarFile …

摘自 Gaowen_HAN的專欄

發佈留言