passing -D argument with white spaces on UNIX

W

wenmang

Hi,

I try to pass a value to overwrite a value defined in the property
file by using following command on unix:
java -DMYENV="my value here" javaClass...

java cannot interpret it correctly, how can I get around it?

Thanks
WM
 
G

Gordon Beaton

I try to pass a value to overwrite a value defined in the property
file by using following command on unix:
java -DMYENV="my value here" javaClass...

java cannot interpret it correctly, how can I get around it?

It should work just fine like that. The quotation marks aren't even
passed to Java, they're only used by the shell to keep the argument
together.

Exactly how does the received value differ from what you've typed on
the command line?

/gordon
 
A

A. Bolmarcich

Hi,

I try to pass a value to overwrite a value defined in the property
file by using following command on unix:
java -DMYENV="my value here" javaClass...

java cannot interpret it correctly, how can I get around it?

You should invoke Runtime.exec(String []) instead of Runtime.exec(String).
With the former, you are responsible for parsing the command into
arguments. With the later, Java parses the command into argument.

For example, use

exec(new String[] {"java", "-DMYENV=my value here", "javaClass"});
 
L

Lloyd

wenmang said:
Hi,

I try to pass a value to overwrite a value defined in the property
file by using following command on unix:
java -DMYENV="my value here" javaClass...

Have you tried single quotes as in java -DMYENV='my value here' javaClass...
 

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

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top