AndreG
Posts: 57
Joined: Tue Jun 10, 2014 11:41 am

Can I have conditional JVM Parameters in my setup?

Mon Jul 03, 2017 3:05 pm

I've got a setup package for a Java desktop app that uses a single JVM parameter to control some of the runtime logic, but now that we're moving the app from batch file launching to an AI project, I'm battling to work out how to control this from the setup wizard...

I have confirmed that having this parameter in the generated "ini" file does indeed get passed to the program, but I would like to have a checkbox in the setup wizard that includes this custom parameter if checked, but excludes it entirely if it is not checked.

Please could somebody help me work out how to achieve this?

Edit: If it matters at all, when I want to use this option from command line I run it with "java -jar AppName.jar mystring", not "-Dmystring", so I believe the parameter I need to add should actually be in the "Command line" field, not the "JVM parameters" field..

AndreG
Posts: 57
Joined: Tue Jun 10, 2014 11:41 am

Re: Can I have conditional JVM Parameters in my setup?

Tue Jul 04, 2017 9:49 am

I've tried using a property in the "Install Parameters" page to store the string I need to conditionally add to the runtime parameters, thinking I could use the current checkbox state to change it's value between a single space (because it can't be an empty string) and the "pdfonly" string that I want to use. But I can't get the value of that property to update, so our app is always installed with 'cmd=" "' in the wrapper's INI file.

Am I even heading in the right direction here? If so, what am I missing? If not, how should I configure this conditional parameter?

Daniel
Posts: 8237
Joined: Mon Apr 02, 2012 1:11 pm
Contact:  Website

Re: Can I have conditional JVM Parameters in my setup?

Wed Jul 05, 2017 10:17 am

Hello,

Adding the custom parameter into an installer property is the correct approach indeed. You can create a public installer property like this:
  • Name: PARAM_PROP
    Value: paramNameandValue
Then you should go to "Java Products" page -> "Virtual Machine" tab and add a formatted reference of the above property (i.e. [PARAM_PROP]) in the "JVM Parameters" or "Command Line" fields as you need.

Finally, you should add in "Custom Actions" page a "Set installer property" action with sequence scheduled after "Install Execution Stage -" Searches" action group like this:
  • Property: PARAM_PROP
    Value: {} //this will set the property value to empty string
    Condition: NOT CHECKBOX_PROP
Let us know if this helped.

All the best,
Daniel
Daniel Radu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

AndreG
Posts: 57
Joined: Tue Jun 10, 2014 11:41 am

Re: Can I have conditional JVM Parameters in my setup?

Fri Jul 07, 2017 2:48 pm

Ah... I didn't think to try the Custom Actions route. From some of the options I saw, it looked as though I could achieve this through the "Published Events" in the Dialogs page.

We've been migrating a number of (badly written) Java programs from one server to another this week, so I haven't had a chance to get back to this installer just yet.. I'll implement it the way you've suggested on Monday morning then.

Thanks Daniel, I appreciate the help. :)

AndreG
Posts: 57
Joined: Tue Jun 10, 2014 11:41 am

Re: Can I have conditional JVM Parameters in my setup?

Mon Jul 10, 2017 8:11 am

Thanks again Daniel, I managed to get this working perfectly using the custom action you described. :)

Daniel
Posts: 8237
Joined: Mon Apr 02, 2012 1:11 pm
Contact:  Website

Re: Can I have conditional JVM Parameters in my setup?

Mon Jul 24, 2017 8:40 am

You're always welcome.

All the best,
Daniel
Daniel Radu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Building Installers”