Using INSTALL_PATH in Java properties

84 views
Skip to first unread message

Phil Hyde

unread,
Oct 4, 2016, 12:31:32 PM10/4/16
to izpack-user
I am using the TargetPanel to choose a location folder.  

As part of my install, I have a Java properties file for my application (parseable) which contains several paths.  For example:

     system.BinDir = ${INSTALL_PATH}${FILE_SEPARATOR}my_app${FILE_SEPARATOR}bin

Our Java application is deployed within Tomcat.  On Windows, I have found for certain Java properties we either need to use a single forward slash "/" or multiple backslashes "\\".

On Windows, multiple backslashes works.  E.g. "c:\\appl\\".

The built-in variable INSTALL_PATH gets set exactly to a folder.  For example "C:\appl" on windows.  This is problematic because of the single backslash.  I could replace c:\ with c:\\ and my problem would be solved

Has anyone found a creative solution to make this work in a reusable way?  




Phil Hyde

unread,
Oct 4, 2016, 12:47:40 PM10/4/16
to izpack-user
After reading the documentation on Dynamic Variables, what I think I want is to use a regex replace, and modify the install path (e.g. C:\appl) to C:\\appl.

Anybody got an example of something like this?

Phil Hyde

unread,
Oct 4, 2016, 1:11:59 PM10/4/16
to izpack-user
Did some testing based on typical regex patterns.  Cannot get this to work:

<variable name="TEST_PATH"  value="${INSTALL_PATH}">
            <filters>
                <regex regexp="/\\/g" replace="\\\\" />
            </filters>
</variable>

Phil Hyde

unread,
Oct 4, 2016, 1:54:47 PM10/4/16
to izpack-user
More testing.  This appears to work, but I would appreciate any feedback.

                <regex regexp="[\\\\]" replace="\\\\\\\\" global="true"/>

René Krell

unread,
Oct 5, 2016, 8:41:01 AM10/5/16
to izpack-user


Dne úterý 4. října 2016 19:54:47 UTC+2 Phil Hyde napsal(a):
More testing.  This appears to work, but I would appreciate any feedback.

                <regex regexp="[\\\\]" replace="\\\\\\\\" global="true"/>


Maybe a better approach would be using just slashes for each OS, for instance 
:
<variable name="previous.JAVA_HOME" escape="false" file="${INSTALL_PATH}/env.cmd" type="options" key="SET JRE" ignorefailure="true">
<filters>
<regex regexp="[/\\]+" replace="/" global="true" />
<regex regexp="[&quot;']+" replace="" global="true" />
</filters>
</variable>

For your example, to normalize all separators to the native one for Windows, there should work this expression:

<regex regexp="[/\\]+" replace="\\\\" global="true" />
 

Phil Hyde

unread,
Oct 5, 2016, 2:10:17 PM10/5/16
to izpack-user
Thanks.

Where do I find this "env.cmd" you referenced?  Or is this just an example?

Phil Hyde

unread,
Oct 5, 2016, 2:20:49 PM10/5/16
to izpack-user
I tried your suggestion:


  <regex regexp="[/\\]+" replace="\\\\" global="true" />

And this does not seem to work for me.   I am using INSTALL_PATH set to C:\appl.  Your code does not change it.

René Krell

unread,
Oct 5, 2016, 3:26:53 PM10/5/16
to izpac...@googlegroups.com

Dne 5. 10. 2016 20:20 napsal uživatel "Phil Hyde" <phil...@gmail.com>:


>
> I tried your suggestion:
>
>
>   <regex regexp="[/\\]+" replace="\\\\" global="true" />
>
> And this does not seem to work for me.   I am using INSTALL_PATH set to C:\appl.  Your code does not change it.

Of course, this is expected. I forgot you want two backslashes. For this purpose, use:

Phil Hyde

unread,
Oct 6, 2016, 10:51:38 AM10/6/16
to izpack-user
This works too.  Thanks!


On Wednesday, October 5, 2016 at 2:26:53 PM UTC-5, René Krell wrote:

Dne 5. 10. 2016 20:20 napsal uživatel "Phil Hyde" <phil...@gmail.com>:

>Of course, this is expected. I forgot you want two backslashes. For this purpose, use:

Reply all
Reply to author
Forward
0 new messages