1 Public classtesttmp {2 Public Static voidMain (string[] args) {3 //TODO auto-generated Method Stub4 for(inti=0;i<args.length;i++){5System.out.println (i+ "=" +args[i]);6 }7 }8 } 9 Ten Public classtesttmp { One Public Static voidMain (string[] args) { A //TODO auto-generated Method Stub - for(inti=0;i<args.length;i++){ -System.out.println (i+ "=" +Args[i]); the } - } -}
Note: The class is created under the default package path;
2. Compiling: Javac Testtmp.java
3. Packing: Jar CVF Test.jar Testtmp.java
4, Update MANIFEST.MF content, add a line main-class: (space) Testtmp.java pay attention to enter,
Unzip Test.jar edit MANIFEST.MF, then compress.
5, Jar UMF MANIFEST. MF Test.jar (update manifest.mf to Test.jar file, you must guarantee two files in the same directory)
6. Test Result: Java code
1 0 1 d:\ 0 1 1 2
D:\>java-jar Testtmp.jar = 1d:\>java-jar Testtmp.jar 1 20 = 11 = 2
Note: If a run exception occurs, it is possible that the Java version of the runtime differs from the compiled Java version, modifying the path of the environment variable;
7. Special Circumstances:
If you need to reference some jar packages, here's how:
Add a line to the MANIFEST.MF, the keyword is class-path,
Format: Class-path: (space) Class1.jar (space) Class2.jar (space) Class3.jar
8. FAQ:
Http://hi.baidu.com/xffys/blog/item/d3bd2c4e92b23fc0d0c86a0b.html
http://hufeng.iteye.com/blog/574339
Java Package/Command line run Jar (command line for program testing)