Automatic modules and jpackage
Alexey Semenyuk
alexey.semenyuk at oracle.com
Mon Nov 27 20:51:12 UTC 2023
Hi Mark,
Good to know you've sorted out the issue. I replied to your email last
week, but didn't send it to the right recipients and it got lost.
Resending once again just in case:
If you want your app's modules in app directory, you can specify
external runtime to jpackage with "--runtime-image" cli option. In this
case jpackage will not run jlink and compile in your modules. Instead it
will copy your modules in "app/mods" directory.
You can run jlink before running jpackage and create a runtime you want.
Or you can simply pass $JAVA_HOME as an argument to "--runtime-image"
cli option.
PS Would you mind updating
https://blog.io7m.com/2023/11/10/batch-files-are-your-only-option.xhtml
page with the solution? jpackage is not a dead end 😉 and it will
support WiX v4.
- Alexey
On 11/27/2023 12:15 PM, Mark Raynsford wrote:
> On Mon, 2023-11-27 at 16:09 +0000, Mark Raynsford wrote:
>> As I mentioned in the blog, I feel like almost all of the
>> functionality might already be there (minus a way to get the runtime
>> to use -p instead of -cp internally), it's just that there doesn't
>> appear to be a way to get jpackage to skip one of the steps that
>> causes the failure.
>>
> Well, I feel silly.
>
> It turns out that it _is_ possible. The key part is the --runtime-image
> option. If there's a normal JDK/JRE image in "jre", and the
> application's modules are in "jars", then:
>
> jpackage \
> --runtime-image jre \
> -t app-image \
> --module com.io7m.demo.m3 \
> --module-path jars \
> --name jpackagetest
>
> This will result in an application image where jpackage/lib/app/mods is
> a directory containing the untouched application jars. Additionally:
>
> $ cat jpackagetest/lib/app/jpackagetest.cfg
> [Application]
> app.mainmodule=com.io7m.demo.m3/com.io7m.demo.m3.M3
>
> [JavaOptions]
> java-options=-Djpackage.app-version=20231111
> java-options=--module-path
> java-options=$APPDIR/mods
>
> Running the application shows that it's definitely running in module
> path mode.
>
> I've no idea why I spent all day failing to combine the arguments in
> this particular way. Maybe my work in 2024 is to submit a documentation
> PR that adds this as an example to the jpackage manual page.
>
More information about the core-libs-dev
mailing list