[izpack-user] Calling Java class in installer jar with pack executable

561 views
Skip to first unread message

David Hay

unread,
Feb 28, 2012, 11:26:44 AM2/28/12
to us...@izpack.codehaus.org
Hi,

I need to execute a Java class that will be packaged in the installer jar using the <executable> tag in <pack>.

Struggling to figure out the syntax, specifically what do I use for targetfile?

eg <pack...>
        <executable targetfile="?????"type="jar" class="my.java.class"  stage="postinstall"/>


can someone please advise?

thanks!

David Hay

unread,
Feb 29, 2012, 9:25:15 AM2/29/12
to us...@izpack.codehaus.org
Bump....

Christopher Walzl

unread,
Feb 29, 2012, 12:08:19 PM2/29/12
to us...@izpack.codehaus.org
Hi David,

In the case of a .jar file being your executable, the 'targetfile' would point to this .jar file. For example:

$INSTALL_PATH = /Applications/MyApp (this would be selected by the user during during the installation process)

Assuming the .jar file that contains the class you'd like to execute is in a file called "foo.jar", your executable tag might look like this:

<executable targetfile="$INSTALL_PATH/foo.jar" type="jar" class="my.java.class" stage="postinstall"/>


Hope this helps.

Chris

David Hay

unread,
Feb 29, 2012, 1:06:29 PM2/29/12
to us...@izpack.codehaus.org
HI Chris,

thanks for the info...

Our installer jar file will have different names depending on the build.  It seems to me if the class to be executed is in the installer jar, you should be able to use"." or some other notation to tell IzPack to look there?

Otherwise we have to figure out how to get the name of the installer jar into our install.xml at build time :(

Does such a shortcut exist?

thanks!

Christopher Walzl

unread,
Feb 29, 2012, 2:55:14 PM2/29/12
to us...@izpack.codehaus.org
David,

I'm not sure if IzPack supports the ability of wildcards for <execution> tags.  However, it sounds like a simple solution would be to use some sort of property placeholder for the .jar file name.  When your build runs, it replaces the placeholder value with the name of the actual jar file. If you're using Ant or Maven, this should be pretty easy to do. 

If the name of this file is provided by the user at runtime, you can use IzPack's property placeholder mechanism.

Best of luck,
Chris
Reply all
Reply to author
Forward
0 new messages