HI Team,

I have a piece of java custom codes which needs to be executed before actual installation starts(pre install section). Also few java custom codes needs to be executed before actual un installation starts. Can you please let me know how can i achieve this ?. I will be bundling my own jre with installer under ${installdir}/jre directory. I want to use this jre for running my java custom code.

Thanks, Shiva Prasad T

asked 07 Nov '11, 01:40

shivakmpl's gravatar image

shivakmpl
1333
accept rate: 0%


Running Java applications after installation - such as during Post Installation or Pre Uninstallation should work normally. You can simply use runProgram, such as:

<runProgram>
  <program>jre/bin/java</program>
  <programArguments>-jar "path/to/app.jar"</programArguments>
  <workingDirectory>${installdir}</workingDirectory>
</runProgram>

The above will work if the installer deploys Java runtime into ${installdir}/jre.

However, running Java in Pre Installation is a bit more difficult - since it will require unpacking entire JRE to a temporary directory.

Assuming you bundle your Java as "jre-${platform_name}" (i.e. jre-linux, jre-windows, jre-linux-x64) folder in "jre" component, it would require the following actions:


<!-- delete directory if it existed -->
<deleteFile>
  <path>${system_temp_directory}/jre-temp</path>
</deleteFile>

<!-- unpack JRE -->
 <unpackDirectory>
   <component>jre</component>
   <destination>${system_temp_directory}/jre-temp</destination>
   <folder>jre${platform_name}</folder>
   <origin>jre</origin>
 </unpackDirectory>

<!-- unpack JAR that is needed -->
 <unpackFile>
   <component>jars</component>
   <destination>${system_temp_directory}/jre-temp/test.jar</destination>
   <folder>jars</folder>
   <origin>test.jar</origin>
 </unpackFile>

<!-- run the application -->
 <runProgram>
   <program>bin/java</program>
   <programArguments>-jar test.jar</programArguments>
   <workingDirectory>${system_temp_directory}/jre-temp</workingDirectory>
 </runProgram>

<!-- clean up -->
 <deleteFile>
   <path>${system_temp_directory}/jre-temp</path>
 </deleteFile>

The jars are assumed to be a test.jar file in "jars" component, "jars" folder.

The names of components and folders are the short names (<name> tag) for components and folders that contain JRE and JAR files respectively.

You can find more information on unpacking files before installation here

link

answered 07 Nov '11, 05:10

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:

×1

Asked: 07 Nov '11, 01:40

Seen: 1,443 times

Last updated: 07 Nov '11, 06:35

Related questions