aspose file tools
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 OCA Java SE 8 Programmer I Study Guide 1Z0-808 this week in the OCAJP 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: 3274

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

It is sorta covered in the JavaRanch Style Guide.
subject: Escaping & in command prompt