简体   繁体   English

使用特定的静态方法而不是终端中的main运行Jar文件

[英]Run Jar file with specific static method instead of the main in terminal

I have a jar file, and I need to use a static method on that. 我有一个jar文件,我需要使用静态方法。 I try to run the command as following from the terminal, but it always runs the main function. 我尝试从终端运行以下命令,但它始终运行main函数。

java -cp myJarFile.jar:com.test.ClassA ClassA StaticMethodA "arg1"

It always uses main function instead of StaticMethodA... Who can help me with this issue? 它总是使用main函数而不是StaticMethodA ...谁可以帮我解决这个问题? I just want the result of StaticMethodA("arg1"). 我只想要StaticMethodA(“arg1”)的结果。

Thanks. 谢谢。

Main method is entry point for you class which designed to be runner. 主要方法是为跑步者设计的班级的切入点。 In main method call your static method by passing argument to it. 在main方法中,通过向其传递参数来调用静态方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM