If I have jar file of java application and supporting jars then what are the steps for creating installer using installBuild tool. Also how can I start my application on windows startup after creating installer?

asked 10 Apr '12, 05:22

TTH's gravatar image

TTH
1111
accept rate: 0%


InstallBuilder's Java support page gives you a really good start. http://installbuilder.bitrock.com/java/

The link includes different compressed Java packages for various platforms. Just expand them; then put all of the subfolders in one place. I use these:

  • installbuilder-8.2.0/jre1.7.0_04/java-linux
  • installbuilder-8.2.0/jre1.7.0_04/java-linux-64
  • installbuilder-8.2.0/jre1.7.0_04/java-windows

Each compressed package has its own java.xml. The only difference between the different java.xml files is the value of a variable called "java_bitness", where it's different for 32 vs 64 bit platforms:

<setInstallerVariable name="java_bitness" value="32" />
<setInstallerVariable name="java_bitness" value="64" />

So, I consolidated them into one by making two changes. Now, I can use only one java.xml in my installer package. The changes include:

  1. Change existing value to refer to a variable:

    <setInstallerVariable name="java_bitness" value="${host_bitness}" />

  2. Create a new action list that sets the new ${host_bitness} variable:

    <initializationActionList> <setInstallerVariable> <name>host_bitness</name> <value>32</value> </setInstallerVariable> <setInstallerVariable> <name>host_bitness</name> <value>64</value> <ruleList> <platformTest> <type>linux-x64</type> </platformTest> </ruleList> </setInstallerVariable> <setInstallerVariable> <name>host_bitness</name> <value>64</value> <ruleList> <platformTest> <type>windows-x64</type> </platformTest> </ruleList> </setInstallerVariable> <setInstallerVariableFromScriptOutput> <exec>isainfo</exec> <execArgs>-v</execArgs> <name>solaris_bitness</name> <ruleList> <platformTest> <type>solaris</type> </platformTest> </ruleList> </setInstallerVariableFromScriptOutput> <setInstallerVariable> <name>host_bitness</name> <value>64</value> <ruleList> <compareText> <logic>contains</logic> <nocase>1</nocase> <text>${solaris_bitness}</text> <value>64</value> </compareText> </ruleList> </setInstallerVariable> </initializationActionList>

I would suggest the InstallBuilder team incorporate these changes to next program update.

Finally, this java.xml component does not detect existing Java installations. So, I have another java-detect.xml component that uses <autodetectJava> and installs the new package only if Java is not detected on the host. This component also detects if the host is a Debian Linux distribution and if the users is running as superuser. It then uses apt-get to install java, no the packages here. This could be expanded to include yum for Redhat/Fedora, and other package managers for other distros. If anyone is interested in this component, I'll be happy to share it somewhere.

link

answered 13 May '12, 02:05

tahoar's gravatar image

tahoar
201313236
accept rate: 42%

If your application is a Java jar file, you could either require the Java runtime to be installed in the target machine or bundle it within your installer.

You could also try to autodetect it using the <autodetectJava> action, and if you cannot find any valid version, either unpack a bundled one or throw an error:

<autodetectJava>
  <abortOnError>0</abortOnError>
  <promptUser>0</promptUser>
  <showMessageOnError>0</showMessageOnError>
</autodetectJava>
<throwError text="Java is required but was not found.
  Please install it an relaunch this installer">
  <ruleList>
    <isFalse>
      <value>${java_autodetected}</value>
    </isFalse>
  </ruleList>
</throwError>

You could even download it at runtime:

 <actionGroup>
         <actionList>
            <showProgressDialog>
              <title>Downloading files</title>
              <actionList>
                <httpGet>
                  <filename>${installdir}/java.tar.gz</filename>
                  <url>http://www.example.com/downloads/java/1.6/jre1.6.0_24-linux.tar.gz</url>
                </httpGet>
              </actionList>
            </showProgressDialog>
            <runProgram>
              <program>tar</program>
              <programArguments>xzf ${installdir}/java.tar.gz -C ${installdir}</programArguments>
            </runProgram>
         </actionList>
         <ruleList>
            <isFalse>
               <value>${java_autodetected}</value>
            </isFalse>
         </ruleList>
      </actionGroup>

You could also create a luncher for your jar file:

  <createJavaLaunchers>
    <destination>${installdir}/javalaunchers</destination>
    <javaLauncherList>
      <javaLauncher>
        <binaryName>launcher1</binaryName>
        <classpath>testapplication.jar;additional.jar</classpath>
        <mainClass>com.bitrock.testapplication.MainClass</mainClass>
        ...
        <windowsResourceFileVersion>1.0.0.0</windowsResourceFileVersion>
        <windowsResourceLegalCopyright>Test Launcher 1</windowsResourceLegalCopyright>
        <windowsResourceLegalTrademarks>(c) 2010 Bitrock S.L.</windowsResourceLegalTrademarks>
        <windowsResourceOriginalFilename>launcher1.exe</windowsResourceOriginalFilename>
        <windowsResourceProductName>Test launcher 1</windowsResourceProductName>
        <windowsResourceProductVersion>1.0</windowsResourceProductVersion>
        <workingDirectory>${installdir}/javalaunchers</workingDirectory>
      </javaLauncher>
   </javaLauncherList>
  </createJavaLaunchers>

You can find additional information in our online documentation.

Regarding starting the application at startup, if you create a launcher you could just create a shortcut to the startup menu

<createShortcuts>
    <destination>${windows_folder_startup}/</destination>
    <shortcutList>
        <shortcut>
            <comment>Client for managing myapp</comment>
            <name>Launch myapp client</name>
            <runAsAdmin>1</runAsAdmin>
            <windowsExec>${installdir}/javalaunchers/launcher1.exe</windowsExec>
            <windowsExecArgs>--dock</windowsExecArgs>
            <windowsPath>${installdir}</windowsPath>
        </shortcut>
    </shortcutList>
</createShortcuts>
link

answered 10 Apr '12, 12:20

juanjo's gravatar image

juanjo ♦♦
5.8k413
accept rate: 23%

-2

Just use actual installer that sripting tool. http://www.actualinstaller.com

link

answered 12 May '12, 08:56

Rust's gravatar image

Rust
-11
accept rate: 0%

It's really uncool to advertise another product on Bitrock's support forum!

(13 May '12, 01:26) tahoar
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:

×156
×40
×15

Asked: 10 Apr '12, 05:22

Seen: 11,014 times

Last updated: 13 May '12, 02:06