New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow for a "bootstrap" script to be run before application start #122
Comments
Hi @keastrid! I've been thinking about this. On Mac and Linux I think it's relatively easy to implement the execution of a script at startup, since we use our own scripts to start the application. But it isn't like that in the case of Windows, where we have a binary generated with launch4j, and it doesn't have an option that allows us to execute anything at the beginning. Any suggestions? Maybe a batch file (converted to EXE and edited to have an icon and other metadata attached) which launch the bootstrap script and then the binary.
Why do you think that this is not a good alternative? |
I don't think its a good alternative as, in my case of a jre updater, it essentially requires download -> unpack -> start timer immediately and shutdown, or wait for user confirmation and do the timer and shutdown. It is also easier to get the application into a bad state, as the process could be killed while it is running leaving the application seemingly unusable from a user perspective. A startup script that can do so can more easily inspect the state of the working directory and determine how it should rename things, so it can recover from a failed move/rename by automatically reverting to the backup. |
Work in progress in branch issue-122. |
I've just implemented and tested this feature for Mac OS, and it seems to work fine. you have to use scripts {
bootstrap = file('path/to/your/bootstrap.sh')
} The specified bootstrap script is copied to |
Also works on Linux! |
I don't know how to implement this feature for Windows. Any suggestions would be welcome! I think we need a separate EXE from the JVM, which has to be executed from the application, or use a BAT file as startup. This is how Google Chrome does it. |
A separate exe may be the better option, as things like IntelliJ software and Chrome use exes rather than scripts. |
I managed to run a startup script on Windows. For this we need a VBS script and a shortcut pointing to it. The VBS script runs the bootstrap script and finally runs the binary. Shortcut can be configured with an icon. Installers also generate shortcuts pointing to the VBS script file. |
Please, try this feature for all platforms as soon as you can, so I can release v1.6.0 to Maven Central. Thanks!! |
Thanks! |
Shortcuts must be generated by installers, as it's not possible to make them reference to relative paths, so It has no sense to package a pre-built shortcut with the app |
There was a bug that I just fixed. |
The problem was that the bootstrap script execute permissions were not set when packaging as tarball/zipball |
I think it's time to release v1.6.0! |
JavaPackager v1.6.0 released to Maven Central |
I'm submitting a…
Short description of the issue/suggestion:
The ability to run a script before launching the application's java runtime.
What is the motivation / use case for changing the behavior?
When an application has its own update facility, it is useful especially in long lifetime applications to allow for the bundled jre to be updated, either on user demand or part of its normal update process, without forcing users to entirely reinstall the application. At least on windows, you cannot update the jvm while it is running, forcing the use of an "elevator" process, written as a shell script or some other application, to update it.
Rather than starting a new process on a timer to rename the folders (eg.
jre
->jre.old
,jre.new
->jre
) and immediately shutting down the program, it would be more useful to have a script capable of doing so on program startup, hence a bootstrap script.I imagine others may have more uses for this feature.
Please tell us about your environment:
Other information (e.g. related issues, suggestions how to fix, links for us to have context)
The text was updated successfully, but these errors were encountered: