Run a class in jar file
Run a class in jar file:
java -cp <jar_file.jar> <class_in_jar_with_absolute_path>
Example:
MyJar.jar contents:
com.example.SomeClass1.class
com.example.SomeClass2.class
com.example.test.Main1.class
com.example.test.Main2.class
com.example.test.Main3.class
Note: Here com, example and test are folders that form the package/folder structure
Run Main2 as:
java -cp MyJar.jar com.example.test.Main2
Written by karthic
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Java
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#