Java jar
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,对格式要求很高,注意每个冒号后面要有一个空格,文件最后要有一个空行。
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 ...