for my project I need some quite specific features in the launcher launch4j does not provide (and where adding general support for would not make much sense in my opinion). So, I need some way to call custom source code inside the launcher.
Because I wanted to make sure my idea works for what I am trying to achieve, I already extended the launch4j source code (newest CVS version as of 2012-12-10) with the necessary stuff.
Please see the attached patch for my modifications (it probably is easier to explain what I want that way, too... ;-) ).
Here is in short what I did:
- Extend head_src/head.c in the prepare()-method to call "hook functions" in several locations to allow modification of the JVM and Java command line, class path and to give one the possibility to setup environment variables
- provide a header (hook.h) and default implementation (defaulthook.c) for those functions
- modify the Java builder code to add support for overriding the default hook object file with a custom one in the XML config file ("customHeaderHook")
- the patch also contains a bug fix for Util.getJarBasedir(), because that function did not work correctly for me (always returned . as directory)
How does it work?
- By default defaulthook.o gets linked into the launcher
- If you want to have custom code in your launcher, you can copy and extend defaulthook.c and link the new object file into the resulting program instead of defaulthook.o (of course you need to know what you are doing in that case...)
If you are interested, I can also provide the extended "hook file" I created for my project as an example...
What I did not do:
- Extend the GUI for the new parameter
- Ask your opinion on that feature in advance... ;-)
It would be very nice if you could consider adding my patch to your project.
If you have a better idea how my requirements can be met (calling custom code from the launcher that can modify the command line), please also let me know.
Thanks in advance
Log in to post a comment.