That's because *
is a shell wildcard: it has a special meaning to the shell, which expands it before passing it on to the command (in this case, java
).
Since you need a literal *
, you need to escape it from the shell. The exact way of escaping varies depending on your shell, but you can try:
java ProgramName 5 3 "*"
Or:
java ProgramName 5 3 \*
By the way, if you want to know what the shell does with the *
, try printing the content of String[] args
to your main
method. You'll find that it will contain names of the files in your directory.
This can be handy if you need to pass some filenames as command line arguments.
See also