I read such a command line arguments example:
public class Echo {
public static void main (String[] args) {
for (String s: args) {
System.out.println(s);
}
}
}
It runs properly from command line, how could I run it from Jshell?
jshell> Echo.main testing
| created variable testing, however, it cannot be referenced until class main is declared
It report error that failed to be referenced.
You invoke it as any other static method:
Full session:
Note that you can declare your
main
method as follows:This is binary compatible with
String[] args
syntax, but would allow you to invoke it as follows: