开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜