ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Peter Reilly <>
Subject Re: Escapign backslash in java.home
Date Thu, 18 Nov 2004 12:36:03 GMT
Thomas Saxtoft wrote:

>The thing is that the java.home I get from ant already contains the
>My script looks like this:
><target name="createServerXml">
>    <replaceregexp file="${oc4j_home}/config/server.xml"
>    match="&lt;java-compiler [^>]*/>"
>    replace="&lt;java-compiler bindir=&quot;${java.home}/bin&quot;
>  </target>
The backslash is an escape character in regexpression land, so it
will not work using it in the replace attribute.

You need to convert the java.home before using it in the replace string.
Use pathconvert for this:
    <pathconvert targetos="unix" property="java.home.converted">
      <path path="${java.home}"/>
    <echo>java.home.converted is ${java.home.converted}</echo>


>I need to change the backslash contained in the property (java.home) to
>a frontslash, before writing to the file. When written to the file the
>backslash has disappeared, and thus it is too late to replace it.
>By using ${java.home} the idea is always to get the correct path to jdk,
>on either OS; Windows or Linux.
>-----Original Message-----
>From: Conelly, Luis (GE Energy, Non GE, GENE)
>Sent: Monday, November 15, 2004 3:24 PM
>To: Ant Users List
>Subject: RE: Escapign backslash in java.home
>why don't you use forward-slashes instead backslashes?
>It is the same for Java and it fits on Win & *nix systems; of course, it
>won't work the same on any OS, since in Win you have this horrible
>drives concept (C: D: etc)
>(for Win)
>(for *nix)
>bottom line, you have to write properties for both OSes and pick them on
>the fly by using something like <condition> [1] task. This kind of
>operation has been discused in this list several times [2]
>Hope this helps
>To unsubscribe, e-mail:
>For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message