This week's giveaway is in the Spring forum.
We're giving away four copies of REST with Spring (video course) and have Eugen Paraschiv on-line!
See this thread for details.
The moose likes Ant, Maven and Other Build Tools and the fly likes Escaping & in command prompt Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "Escaping & in command prompt" Watch "Escaping & in command prompt" New topic

Escaping & in command prompt

anish do

Joined: Mar 30, 2010
Posts: 3
How to escape & in command prompt. The whole idea is to pass a URL as a command line argument. But that URL contains & symbols. So I am getting the following error.
"'pid' is not recognized as an internal or external command,
operable program or batch file."

See the below ant script
<target name="x" depends="y">
<java classname="${main-class}" fork="true" failonerror="yes">
<path refid="lib.classpath" />
<fileset dir="${z}" includes="**/*.jar" />
<arg value="${URL}" />

Martijn Verburg

Joined: Jun 24, 2003
Posts: 3275

Which operating system are you using? I'd suggest googling "escape characters on command line <insert you OS here>"

Cheers, Martijn - Blog,
Twitter, PCGen, Ikasan, My The Well-Grounded Java Developer book!,
My start-up.
David Newton

Joined: Sep 29, 2008
Posts: 12617

Unix uses the "&" character to put jobs into the background; I don't know if DOS uses it or not.
anish do

Joined: Mar 30, 2010
Posts: 3
I am using windows XP. I can pass the url in double quotes. Thanks for your help. If you know any other ways to resolve this issue please let me know

I agree. Here's the link:
subject: Escaping & in command prompt
It's not a secret anymore!