Run class in Jar file
Solution 1:
Use java -cp myjar.jar com.mypackage.myClass
.
If the class is not in a package then simply
java -cp myjar.jar myClass
.-
If you are not within the directory where
myJar.jar
is located, then you can do:-
On Unix or Linux platforms:
java -cp /location_of_jar/myjar.jar com.mypackage.myClass
-
On Windows:
java -cp c:\location_of_jar\myjar.jar com.mypackage.myClass
-
Solution 2:
You want:
java -cp myJar.jar myClass
The Documentation gives the following example:
C:> java -classpath C:\java\MyClasses\myclasses.jar utility.myapp.Cool