The Artima Developer Community
Sponsored Link

Java Answers Forum
Quotes in Command Line Arguments?

3 replies on 1 page. Most recent reply: Sep 7, 2002 5:13 AM by Kenneth S

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 3 replies on 1 page
Curtis D. Blaine

Posts: 2
Nickname: cblaine
Registered: Sep, 2002

Quotes in Command Line Arguments? Posted: Sep 4, 2002 11:21 PM
Reply to this message Reply
Advertisement
I'm using a Windows 95 machine and would like to run a compiled Java program at the command line, using the format:

java HelloWorld arg1 arg2

where arg1 and arg2 are command line arguments. Question: can I have a command line argument like this "John loves Mary", where the entire phrase, and its enclosing quotes, are passed to the program as one argument?

Any help would be greatly appreciated,


Kenneth S

Posts: 3
Nickname: devnio
Registered: Sep, 2002

Re: Quotes in Command Line Arguments? Posted: Sep 6, 2002 6:20 AM
Reply to this message Reply
To pass the argument "John loves Mary" including the quotes you can call you program like this:

java HelloWorld "\"John loves Mary\""
(that is, using the backslash as an escape character)

To pass a set of words as one single argument, enclose the set with quotes, like this:

java HelloWorld "John loves Mary"

Curtis D. Blaine

Posts: 2
Nickname: cblaine
Registered: Sep, 2002

Re: Quotes in Command Line Arguments? Posted: Sep 6, 2002 5:17 PM
Reply to this message Reply
Dear Kenneth S:

Thanks so much for your answer to my question about embedded quotes in a Java command line argument. I never received a response to several previous questions I posted, and I was a bit pessimistic about getting help.

It didn't occur to me to use the escape character approach, as you would do inside a Java program, but that was the answer!

By the way, I am trying to modify a Java program that was provided to me by the people at "Google", that supposedly let's you do Google searches through a Java program, as opposed to through your browser. I'm having some trouble getting it to work, and wonder if you could answer a question or two about the meaning of the error messages I'm getting when I run it.

If you would be willing to help, would it be possible to get your e-mail address, so I could communicate directly with you?

Regardless of whether you can help with this additional program, I greatly appreciate your help with my original question. Thanks again!

Sincerely,
Curtis D. Blaine

Kenneth S

Posts: 3
Nickname: devnio
Registered: Sep, 2002

Re: Quotes in Command Line Arguments? Posted: Sep 7, 2002 5:13 AM
Reply to this message Reply
Sure, that's what this forum is all about. If you prefer, my email address can be found in my profile.

Flat View: This topic has 3 replies on 1 page
Topic: why do we use Enterbrise bean instead of java bean on the server?? Previous Topic   Next Topic Topic: Swing basics..

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use