开发者

java.home property adds extra slashes when it it written to a property file?

As per my understanding, java.home is a A开发者_C百科NT built-in property. In our scenerio, we write the value of java.home to a another property file in the same project . Hovewer, we observed that when we write the value of java.home to the aforesaid property file, the value is written with additional slashes(e.g: ‘d:/jdk1.6.0_12’ value is written to aforesaid property file as ‘d\:\\jdk1.6.0_12\\jre’) and these additional slashes are causing issues in our system.

So, I need your suggestion/help/input to know 1) if there is a way to write java.home to another property file without additional slashes OR 2)if there is a way to write script in ANT build file such that when java.home property will be read from aforesaid property file which containss additional slashes, the script will chop-off unwanted/additional slashes and will return the exact path to java.home .


In a property-file, the \ is an escape-character, which is used to escape all characters which have special meanings in the property-file-syntax, like a : here. It should be stripped of when reading the property file. Isn't it?

For exporting the value, maybe a simple <echo file="...">${java.home}</echo> instead of the property-file-export would be more useful?


Here is a solution to this problem:

<path id="property.toreplace.path">
    <pathelement path="${property.toreplace}"/>
</path>
<pathconvert targetos="unix" property="formatted.property.toreplace" refid="property.toreplace.path"/>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜