Program cannot recognize asterisk(*) as an argument passed from the command line?

F

Fong

I try to pass 3 parameters from the command line to a program.
However, the asterisk(*) cannot be recognized by the Java Interpreter,
unless it is embedded by the double quotes(""). There is no problem
with the other symbols like question mark(?), percentage(%), etc. Why
is it like that? Does anyone know why?

Thanks in advance.

Fong
 
M

Michael Borgwardt

Fong said:
I try to pass 3 parameters from the command line to a program.
However, the asterisk(*) cannot be recognized by the Java Interpreter,
unless it is embedded by the double quotes(""). There is no problem
with the other symbols like question mark(?), percentage(%), etc. Why
is it like that? Does anyone know why?

Most likely * is interpreted as a file wildcard and replaced by a list
of all files in the current directory, while ? (also a file wildcard)
is passed on because there is no file it matches.
 
G

Gordon Beaton

I try to pass 3 parameters from the command line to a program.
However, the asterisk(*) cannot be recognized by the Java
Interpreter, unless it is embedded by the double quotes(""). There
is no problem with the other symbols like question mark(?),
percentage(%), etc. Why is it like that? Does anyone know why?

Read the documentation for your command shell, which recognizes and
processes some special characters before passing them to the
application, which only sees the results of the processed characters.
By quoting or escaping (\*) them, you indicate to the shell that you
want them to be treated as normal characters.

/gordon
 
F

Fong

Michael Borgwardt said:
Most likely * is interpreted as a file wildcard and replaced by a list
of all files in the current directory, while ? (also a file wildcard)
is passed on because there is no file it matches.

Thanks for your information!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top