Running a Java Class from a Jar thru a command line
I have a jar file with several classes w开发者_运维百科hich have static main methods. Can I execute them inside the jar from the command line? If not, can I execute them one by one?
Windows
java -classpath .;path/to/yourlib.jar your.package.path.ClassWithMain
Linux (I guess)
java -classpath .:path/to/yourlib.jar your.package.path.ClassWithMain
Or if you don't use packages just do (for Windows)
java -classpath .;path/to/yourlib.jar ClassWithMain
If you don't know which class has static main method,you can use some java IDE,for example IntelliJ IDEA,it can find the classes with main() method,and then you can run it within your project.
精彩评论