jpackage --type app-image creates infinite recursive directories
Asked Answered
P

1

6

I'm trying to use jpackage to create an installer for my Java app. I'm on Windows 10 using OpenJDK 15.0.1. I can build an installer using

jpackage --input C:\MyApp --main-jar MyApp.jar

This basically works, but the installed application lacks resource files. According to the documentation, I should be able to build an app image, add my resource files to the image, then build the installer from the modified app image, as follows

jpackage --type app-image -n MyAppImage
copy <resource files> MyAppImage
jpackage --app-image MyAppImage --name MyAppInstaller

However, when I try jpackage --type app-image the process never terminates, and I have to kill it with control-C. When I examine the MyAppImage directory, it has a subdirectory app, which more or less mirrors the contents of C:\MyApp. Those contents include MyAppImage, which recursively gets copied into the app subdirectory, creating a potentially infinite set of directories: C:\MyApp\MyAppImage\app\MyAppImage\app\MyAppImage ...

If I manually delete app\MyAppImage and try jpackage --app-image, jpackage crashes with a java.io.IOException.

Has anyone else encountered this? What should I try?

Phyllis answered 8/11, 2020 at 17:50 Comment(1)
Also came across this horrible bug. Was unable to delete it using any windows tools, had to use a Linux shell emulator run the rm tool to delete everything.Patterman
P
5

It turns out that the shell working directory makes a difference. The directory specified by --input should not be the same as the directory where the app image will be created.

I fixed the problem by creating a subdirectory C:\MyApp\build and copying MyApp.jar to build.

cd C:\MyApp
mkdir build
copy MyApp.jar build
jpackage --type app-image --n MyAppImage --input C:\MyApp\build --main-jar MyApp.jar

The recursive file-copying doesn't happen any more. But I'm still getting an error when running jpackage --app-image. I'll make that the subject of a subsequent post.

Phyllis answered 8/11, 2020 at 22:54 Comment(1)
Same solution, but instead of copying the file manually, I have used the one created by mvn install under ~/.m2/repository/mylib/myapp/app-1.0-SNAPSHOTHearse

© 2022 - 2024 — McMap. All rights reserved.