Friday, November 11, 2011

Java : How to Run a Jar file

If you need to run a JAR file in JAVA, use below mentioned command

java -jar Test.jar

Note : In this case Manifest.txt inTest.jar should contain Entry Point i.e. Class which has main method in it.

Main-Class: MyPackage.MyClass

In some cases if there are multiple Entry points i.e. there is not any specific Main-Class in Manifest and you need to provide main class at run time then you can use below mentioned simple method.

java -cp Test.jar MyPackage.MyClass1
 
java -cp Test.jar MyPackage.MyClass2


No comments:

Post a Comment