[英]Calling a static jar class method from command line
I have a jar file : "CallMeMaybe.jar". 我有一个jar文件:“CallMeMaybe.jar”。
There is a static method callMe() in the main class callmemaybe.CallMeMaybe . 主类callmemaybe.CallMeMaybe中有一个静态方法callMe()。 Like it is possible to call the main() method from command line by running :
就像可以通过运行以下命令从命令行调用main()方法:
java -cp CallMeMaybe.jar callmemaybe.CallMeMaybe
Is there a way to directly call another static method than main() ? 有没有办法直接调用另一个静态方法而不是main()?
I would like to do that : 我想这样做 :
java -cp CallMeMaybe.jar callmemaybe.CallMeMaybe.callMe()
You can't call it directly , but just call it from your main method ie 你不能直接调用它,而只是从你的main方法调用它,即
public class Foo {
public static void main(String[] args) {
doSomething(args);
}
private static void doSomething(String[] args) {
// your code here
}
}
Although I don't see the point of the extra method. 虽然我没有看到额外方法的意义。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.