I need to run a Java program to query the user's system, and then present a set of choices based on the output from the Java program.

How do I integrate this with InstallBuilder?

thanks.

asked 20 Mar '12, 11:08

bstoke's gravatar image

bstoke
16222224
accept rate: 0%


You can just call the Java program and return the result as the stdout. Then, you can populate the options using the <addChoiceOptionsFromText> action:

<parameterList>
  <choiceParameter>
    <name>choice</name>
    <displayType>combobox</displayType>
    ...
  </choiceParameter>
</parameterList>
...
<runProgram>
   <program>${java_bin_dir}/java</program>
   <programArguments>-jar ${installdir}/yourprogram.jar</programArguments>
</runProgram>
<!-- Process the stdout to get the appropriate format -->
 ....
<addChoiceOptionsFromText>
   <name>choice</name>
   <text>${processed_text}</text>
</addChoiceOptionsFromText>

Please note that if you want to configure the choice parameter before the installation stage you will need to use an <unpackFile> action to unpack the jar file and the Java runtime (if you are not using the one from the system).

You can find some more details in the below links:

Run Program after Install and present Choices

Populating Parameters at runtime

link

answered 20 Mar '12, 11:31

juanjo's gravatar image

juanjo ♦♦
5.8k413
accept rate: 23%

It is possible to run a Java JAR before installation is performed and based on its output or exit code perform certain actions - such as set whether parameter should be shown.

Below is an example of finding Java, unpacking a JAR file, running it and setting if installdir parameter should be shown based on if exit code is 0:

<preInstallationActionList>
  <autodetectJava>
    <promptUser>0</promptUser>
  </autodetectJava>
  <unpackFile>
    <component>myjar</component>
    <destination>${system_temp_directory}/myjar.jar</destination>
    <folder>myjar</folder>
    <origin>myjar.jar</origin>
  </unpackFile>
  <runProgram>
    <program>${java_executable}</program>
    <programArguments>-jar "${system_temp_directory}/myjar.jar"</programArguments>
  </runProgram>
  <deleteFile>
    <path>${system_temp_directory}/myjar.jar</path>
  </deleteFile>
  <if>
    <actionList>
      <setInstallerVariable>
        <name>project.parameter(installdir).show</name>
        <value>0</value>
      </setInstallerVariable>
    </actionList>
    <conditionRuleList>
      <compareValues>
        <logic>equals</logic>
        <value1>${program_exit_code}</value1>
        <value2>0</value2>
      </compareValues>
    </conditionRuleList>
    <elseActionList>
      <setInstallerVariable>
        <name>project.parameter(installdir).show</name>
        <value>1</value>
      </setInstallerVariable>
    </elseActionList>
  </if>
</preInstallationActionList>

It is also possible to populate choice parameter options using <addChoiceOptions> or <addChoiceOptionsFromText> actions.

Based on what exactly you want to do, you can find additional information in our User Guide:

link

answered 20 Mar '12, 11:32

wojciechka's gravatar image

wojciechka ♦♦
7.8k61122
accept rate: 26%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×40
×11
×11

Asked: 20 Mar '12, 11:08

Seen: 1,878 times

Last updated: 20 Mar '12, 11:32