In java, you can pass cmd line arguments to the main()
method during program startup.
I'd like to pass cmd line arguments to a specific method that I call from a script directly. I'd had no luck just entering them as I would for main()
.
Example:
public class Test {
public static void main(String[] args) { // args is cmd line input
// do stuff with args
}
}
You would do: ~]# java Test cmdlineinput
I need to do:
public class Test {
public void someMethod(String input) {
// do stuff with input
}
}
I want to do: ~]# java Test.someMethod cmdlineinput
Is this possible and how so?