Home > Mobile >  JPackage doesn't generate working exe and bugs folders
JPackage doesn't generate working exe and bugs folders

Time:10-05

I'm trying to make a portable exe from my jar app using JPackage. I used jdk16 and maven to make the app, the app compiles and runs perfectly. When I tryed to use JPackage something wierd happend, when using -t exe I would sometimes get an exe installer that when executed only played the windows error sound and sometimes closed others had to use task manager, other times generates nothing. Then I tryed using -t app-image (to my understanding the one needed to create portable exe files), now JPackage never stopped runing, just created folders and folders. At this point I created a new project, I'll use this project to explain in more detail my problems since it creates the same ones.

package test;

import javax.swing.JFrame;
import javax.swing.JLabel;

public class Main {

    public static void main(String[] args) {
        JFrame frame = new JFrame();
        frame.add(new JLabel("Hello world!"));
        frame.pack();
        frame.setVisible(true);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    }

}

This is all the code that this test project contains. I exported it and moved the final jar into its own folder and runned the following command on the folder with the jar and a "temp" folder

jpackage -t app-image -n "Test" --temp "temp" --verbose -i "" --main-class "test.Main" --main-jar "Test.jar" --win-console

Although the --verbose is specifyed nothing shows in console until some minutes later I get this

[00:29:39.141] Creating app package: Test in C:\Users\mynem\Desktop\Nueva carpeta\test jpackage 3
[00:29:44.060] Command [PID: -1]:
    jlink --output C:\Users\mynem\Desktop\Nueva carpeta\test jpackage 3\Test\runtime --module-path C:\\Program Files\\Java\\jdk-17\\jmods --add-modules jdk.management.jfr,java.rmi,jdk.jdi,jdk.charsets,jdk.xml.dom,java.xml,java.datatransfer,jdk.jstatd,jdk.httpserver,java.desktop,java.security.sasl,jdk.zipfs,java.base,jdk.crypto.ec,jdk.javadoc,jdk.management.agent,jdk.jshell,jdk.editpad,java.sql.rowset,jdk.sctp,jdk.jsobject,java.smartcardio,jdk.jlink,jdk.unsupported,java.security.jgss,java.compiler,jdk.nio.mapmode,jdk.dynalink,jdk.unsupported.desktop,jdk.accessibility,jdk.security.jgss,java.sql,jdk.incubator.vector,java.transaction.xa,java.xml.crypto,java.logging,jdk.jfr,jdk.crypto.cryptoki,jdk.net,jdk.random,java.naming,jdk.internal.ed,java.prefs,java.net.http,jdk.compiler,jdk.naming.rmi,jdk.internal.opt,jdk.jconsole,jdk.attach,jdk.crypto.mscapi,jdk.internal.le,java.management,jdk.jdwp.agent,jdk.internal.jvmstat,jdk.incubator.foreign,java.instrument,jdk.management,jdk.security.auth,java.scripting,jdk.jdeps,jdk.jartool,java.management.rmi,jdk.jpackage,jdk.naming.dns,jdk.localedata --strip-native-commands --strip-debug --no-man-pages --no-header-files
[00:29:44.060] Output:
    WARNING: Using incubator modules: jdk.incubator.vector, jdk.incubator.foreign

[00:29:44.061] Returned: 0

[00:29:44.064] Using default package resource JavaApp.ico [icon] (add Test.ico to the resource-dir to customize).
[00:29:44.071] Warning: Windows Defender may prevent jpackage from functioning. If there is an issue, it can be addressed by either disabling realtime monitoring, or adding an exclusion for the directory "C:\Users\mynem\Desktop\Nueva carpeta\test jpackage 3\temp".
[00:29:44.781] Using default package resource WinLauncher.template [Template for creating executable properties file] (add Test.properties to the resource-dir to customize).
[00:33:43.032] java.io.IOException: Cannot access file with path exceeding 32000 characters
        at java.base/sun.nio.fs.WindowsException.translateToIOException(WindowsException.java:81)
        at java.base/sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:103)
        at java.base/sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:108)
        at java.base/sun.nio.fs.WindowsFileSystemProvider.createDirectory(WindowsFileSystemProvider.java:521)
        at java.base/java.nio.file.Files.createDirectory(Files.java:700)
        at java.base/java.nio.file.Files.createAndCheckIsDirectory(Files.java:807)
        at java.base/java.nio.file.Files.createDirectories(Files.java:793)
        at jdk.jpackage/jdk.jpackage.internal.IOUtils$2.preVisitDirectory(IOUtils.java:119)
        at jdk.jpackage/jdk.jpackage.internal.IOUtils$2.preVisitDirectory(IOUtils.java:112)
        at java.base/java.nio.file.Files.walkFileTree(Files.java:2817)
        at java.base/java.nio.file.Files.walkFileTree(Files.java:2882)
        at jdk.jpackage/jdk.jpackage.internal.IOUtils.copyRecursive(IOUtils.java:112)
        at jdk.jpackage/jdk.jpackage.internal.IOUtils.copyRecursive(IOUtils.java:107)
        at jdk.jpackage/jdk.jpackage.internal.AbstractAppImageBuilder.copyApplication(AbstractAppImageBuilder.java:74)
        at jdk.jpackage/jdk.jpackage.internal.WindowsAppImageBuilder.prepareApplicationFiles(WindowsAppImageBuilder.java:103)
        at jdk.jpackage/jdk.jpackage.internal.AppImageBundler.createAppBundle(AppImageBundler.java:172)
        at jdk.jpackage/jdk.jpackage.internal.AppImageBundler.execute(AppImageBundler.java:91)
        at jdk.jpackage/jdk.jpackage.internal.Arguments.generateBundle(Arguments.java:676)
        at jdk.jpackage/jdk.jpackage.internal.Arguments.processArguments(Arguments.java:550)
        at jdk.jpackage/jdk.jpackage.main.Main.execute(Main.java:91)
        at jdk.jpackage/jdk.jpackage.main.Main.main(Main.java:52)
[00:33:43.034] Kept working directory for debug: C:\Users\mynem\Desktop\Nueva carpeta\test jpackage 3\temp
[00:33:43.034] jdk.jpackage.internal.PackagerException: java.io.IOException: Cannot access file with path exceeding 32000 characters
        at jdk.jpackage/jdk.jpackage.internal.AppImageBundler.execute(AppImageBundler.java:96)
        at jdk.jpackage/jdk.jpackage.internal.Arguments.generateBundle(Arguments.java:676)
        at jdk.jpackage/jdk.jpackage.internal.Arguments.processArguments(Arguments.java:550)
        at jdk.jpackage/jdk.jpackage.main.Main.execute(Main.java:91)
        at jdk.jpackage/jdk.jpackage.main.Main.main(Main.java:52)
Caused by: java.io.IOException: Cannot access file with path exceeding 32000 characters
        at java.base/sun.nio.fs.WindowsException.translateToIOException(WindowsException.java:81)
        at java.base/sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:103)
        at java.base/sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:108)
        at java.base/sun.nio.fs.WindowsFileSystemProvider.createDirectory(WindowsFileSystemProvider.java:521)
        at java.base/java.nio.file.Files.createDirectory(Files.java:700)
        at java.base/java.nio.file.Files.createAndCheckIsDirectory(Files.java:807)
        at java.base/java.nio.file.Files.createDirectories(Files.java:793)
        at jdk.jpackage/jdk.jpackage.internal.IOUtils$2.preVisitDirectory(IOUtils.java:119)
        at jdk.jpackage/jdk.jpackage.internal.IOUtils$2.preVisitDirectory(IOUtils.java:112)
        at java.base/java.nio.file.Files.walkFileTree(Files.java:2817)
        at java.base/java.nio.file.Files.walkFileTree(Files.java:2882)
        at jdk.jpackage/jdk.jpackage.internal.IOUtils.copyRecursive(IOUtils.java:112)
        at jdk.jpackage/jdk.jpackage.internal.IOUtils.copyRecursive(IOUtils.java:107)
        at jdk.jpackage/jdk.jpackage.internal.AbstractAppImageBuilder.copyApplication(AbstractAppImageBuilder.java:74)
        at jdk.jpackage/jdk.jpackage.internal.WindowsAppImageBuilder.prepareApplicationFiles(WindowsAppImageBuilder.java:103)
        at jdk.jpackage/jdk.jpackage.internal.AppImageBundler.createAppBundle(AppImageBundler.java:172)
        at jdk.jpackage/jdk.jpackage.internal.AppImageBundler.execute(AppImageBundler.java:91)
        ... 4 more

I know in the message says that it's using jdk17 but I also tryed with 16 with the same problem. I suppose that the only reason why JPackage crashed is because the path of the folders got too long since now the folder where I started looks like this

├───temp
└───Test
    ├───app
    │   ├───temp
    │   └───Test
    │       └───app
    │           ├───temp
    │           └───Test
    │               └───app
    │                   ├───temp
    │                   └───Test
    │                       └───app
    │                           ├───temp
    │                           └───Test
    │                               └───app
    │                                   ├───temp
    │                                   └───Test
    │                                                                                       
    └───runtime
        ├───bin
        │   └───server
        ├───conf
        │   ├───management
        │   └───security
        │       └───policy
        │           ├───limited
        │           └───unlimited
        ├───legal
        │   ├───java.base
        │   ├───java.compiler
        │   ├───java.datatransfer
        │   ├───java.desktop
        │   ├───java.instrument
        │   ├───java.logging
        │   ├───java.management
        │   ├───java.management.rmi
        │   ├───java.naming
        │   ├───java.net.http
        │   ├───java.prefs
        │   ├───java.rmi
        │   ├───java.scripting
        │   ├───java.security.jgss
        │   ├───java.security.sasl
        │   ├───java.smartcardio
        │   ├───java.sql
        │   ├───java.sql.rowset
        │   ├───java.transaction.xa
        │   ├───java.xml
        │   ├───java.xml.crypto
        │   ├───jdk.accessibility
        │   ├───jdk.attach
        │   ├───jdk.charsets
        │   ├───jdk.compiler
        │   ├───jdk.crypto.cryptoki
        │   ├───jdk.crypto.ec
        │   ├───jdk.crypto.mscapi
        │   ├───jdk.dynalink
        │   ├───jdk.editpad
        │   ├───jdk.httpserver
        │   ├───jdk.incubator.foreign
        │   ├───jdk.incubator.vector
        │   ├───jdk.internal.ed
        │   ├───jdk.internal.jvmstat
        │   ├───jdk.internal.le
        │   ├───jdk.internal.opt
        │   ├───jdk.jartool
        │   ├───jdk.javadoc
        │   ├───jdk.jconsole
        │   ├───jdk.jdeps
        │   ├───jdk.jdi
        │   ├───jdk.jdwp.agent
        │   ├───jdk.jfr
        │   ├───jdk.jlink
        │   ├───jdk.jpackage
        │   ├───jdk.jshell
        │   ├───jdk.jsobject
        │   ├───jdk.jstatd
        │   ├───jdk.localedata
        │   ├───jdk.management
        │   ├───jdk.management.agent
        │   ├───jdk.management.jfr
        │   ├───jdk.naming.dns
        │   ├───jdk.naming.rmi
        │   ├───jdk.net
        │   ├───jdk.nio.mapmode
        │   ├───jdk.random
        │   ├───jdk.sctp
        │   ├───jdk.security.auth
        │   ├───jdk.security.jgss
        │   ├───jdk.unsupported
        │   ├───jdk.unsupported.desktop
        │   ├───jdk.xml.dom
        │   └───jdk.zipfs
        └───lib
            ├───jfr
            └───security

The "test App" bucle doesn't seem to end, I shortened it since I reached the character limit for a post. Also if I now try to delete the top "Test" folder I get Error 0x80070091: The folder is not empty. and I can't delete it since pressing the try again button makes the windows explorer restart without deleting the folder, so now I have a bounch of folders that I can't delete from all my tests (help on how to delete them is also apreciated).

Then I moved the jar file to its own folder again and created the temp folder, ran the command

jpackage -t exe -n "Test" --temp "temp" --verbose -i "" --main-class "test.Main" --main-jar "Test.jar" --win-console

(Change -t app-image to -t exe) Again, until some minutes go by nothing on console and then

[00:43:45.791] Running candle.exe
[00:43:45.833] Running C:\Program Files (x86)\WiX Toolset v3.11\bin\candle.exe
[00:43:46.193] Running light.exe
[00:43:46.223] Running C:\Program Files (x86)\WiX Toolset v3.11\bin\light.exe
[00:43:46.407] Detected [light.exe] version [3.11.2.4516].
[00:43:46.407] Detected [candle.exe] version [3.11.2.4516].
[00:43:46.408] WiX 3.11.2.4516 detected. Enabling advanced cleanup action.
[00:43:51.431] Command [PID: -1]:
    jlink --output temp\images\win-msi.image\Test\runtime --module-path C:\\Program Files\\Java\\jdk-17\\jmods --add-modules java.rmi,jdk.management.jfr,jdk.jdi,jdk.charsets,jdk.xml.dom,java.xml,java.datatransfer,jdk.jstatd,jdk.httpserver,java.desktop,java.security.sasl,jdk.zipfs,java.base,jdk.crypto.ec,jdk.javadoc,jdk.management.agent,jdk.jshell,jdk.editpad,jdk.sctp,java.sql.rowset,jdk.jsobject,jdk.unsupported,jdk.jlink,java.smartcardio,java.security.jgss,java.compiler,jdk.nio.mapmode,jdk.dynalink,jdk.unsupported.desktop,jdk.accessibility,jdk.security.jgss,jdk.incubator.vector,java.sql,java.xml.crypto,java.transaction.xa,java.logging,jdk.jfr,jdk.crypto.cryptoki,jdk.net,jdk.random,java.naming,jdk.internal.ed,java.prefs,java.net.http,jdk.compiler,jdk.internal.opt,jdk.naming.rmi,jdk.jconsole,jdk.attach,jdk.crypto.mscapi,jdk.internal.le,java.management,jdk.jdwp.agent,jdk.internal.jvmstat,jdk.incubator.foreign,java.instrument,jdk.management,jdk.security.auth,java.scripting,jdk.jdeps,jdk.jartool,java.management.rmi,jdk.jpackage,jdk.naming.dns,jdk.localedata --strip-native-commands --strip-debug --no-man-pages --no-header-files
[00:43:51.431] Output:
    WARNING: Using incubator modules: jdk.incubator.foreign, jdk.incubator.vector

[00:43:51.432] Returned: 0

[00:43:51.435] Using default package resource JavaApp.ico [icon] (add Test.ico to the resource-dir to customize).
[00:43:51.442] Warning: Windows Defender may prevent jpackage from functioning. If there is an issue, it can be addressed by either disabling realtime monitoring, or adding an exclusion for the directory "C:\Users\mynem\Desktop\Nueva carpeta\test jpackage 4\temp".
[00:43:51.532] Using default package resource WinLauncher.template [Template for creating executable properties file] (add Test.properties to the resource-dir to customize).
[00:44:56.974] java.io.IOException: Cannot access file with path exceeding 32000 characters
        at java.base/sun.nio.fs.WindowsException.translateToIOException(WindowsException.java:81)
        at java.base/sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:103)
        at java.base/sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:108)
        at java.base/sun.nio.fs.WindowsFileSystemProvider.createDirectory(WindowsFileSystemProvider.java:521)
        at java.base/java.nio.file.Files.createDirectory(Files.java:700)
        at java.base/java.nio.file.Files.createAndCheckIsDirectory(Files.java:807)
        at java.base/java.nio.file.Files.createDirectories(Files.java:793)
        at jdk.jpackage/jdk.jpackage.internal.IOUtils$2.preVisitDirectory(IOUtils.java:119)
        at jdk.jpackage/jdk.jpackage.internal.IOUtils$2.preVisitDirectory(IOUtils.java:112)
        at java.base/java.nio.file.Files.walkFileTree(Files.java:2817)
        at java.base/java.nio.file.Files.walkFileTree(Files.java:2882)
        at jdk.jpackage/jdk.jpackage.internal.IOUtils.copyRecursive(IOUtils.java:112)
        at jdk.jpackage/jdk.jpackage.internal.IOUtils.copyRecursive(IOUtils.java:107)
        at jdk.jpackage/jdk.jpackage.internal.AbstractAppImageBuilder.copyApplication(AbstractAppImageBuilder.java:74)
        at jdk.jpackage/jdk.jpackage.internal.WindowsAppImageBuilder.prepareApplicationFiles(WindowsAppImageBuilder.java:103)
        at jdk.jpackage/jdk.jpackage.internal.AppImageBundler.createAppBundle(AppImageBundler.java:172)
        at jdk.jpackage/jdk.jpackage.internal.AppImageBundler.execute(AppImageBundler.java:91)
        at jdk.jpackage/jdk.jpackage.internal.WinMsiBundler.prepareProto(WinMsiBundler.java:351)
        at jdk.jpackage/jdk.jpackage.internal.WinMsiBundler.execute(WinMsiBundler.java:399)
        at jdk.jpackage/jdk.jpackage.internal.WinExeBundler.bundle(WinExeBundler.java:104)
        at jdk.jpackage/jdk.jpackage.internal.WinExeBundler.execute(WinExeBundler.java:77)
        at jdk.jpackage/jdk.jpackage.internal.Arguments.generateBundle(Arguments.java:676)
        at jdk.jpackage/jdk.jpackage.internal.Arguments.processArguments(Arguments.java:550)
        at jdk.jpackage/jdk.jpackage.main.Main.execute(Main.java:91)
        at jdk.jpackage/jdk.jpackage.main.Main.main(Main.java:52)
[00:44:56.975] Kept working directory for debug: C:\Users\mynem\Desktop\Nueva carpeta\test jpackage 4\temp
[00:44:56.975] jdk.jpackage.internal.PackagerException: java.io.IOException: Cannot access file with path exceeding 32000 characters
        at jdk.jpackage/jdk.jpackage.internal.AppImageBundler.execute(AppImageBundler.java:96)
        at jdk.jpackage/jdk.jpackage.internal.WinMsiBundler.prepareProto(WinMsiBundler.java:351)
        at jdk.jpackage/jdk.jpackage.internal.WinMsiBundler.execute(WinMsiBundler.java:399)
        at jdk.jpackage/jdk.jpackage.internal.WinExeBundler.bundle(WinExeBundler.java:104)
        at jdk.jpackage/jdk.jpackage.internal.WinExeBundler.execute(WinExeBundler.java:77)
        at jdk.jpackage/jdk.jpackage.internal.Arguments.generateBundle(Arguments.java:676)
        at jdk.jpackage/jdk.jpackage.internal.Arguments.processArguments(Arguments.java:550)
        at jdk.jpackage/jdk.jpackage.main.Main.execute(Main.java:91)
        at jdk.jpackage/jdk.jpackage.main.Main.main(Main.java:52)
Caused by: java.io.IOException: Cannot access file with path exceeding 32000 characters
        at java.base/sun.nio.fs.WindowsException.translateToIOException(WindowsException.java:81)
        at java.base/sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:103)
        at java.base/sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:108)
        at java.base/sun.nio.fs.WindowsFileSystemProvider.createDirectory(WindowsFileSystemProvider.java:521)
        at java.base/java.nio.file.Files.createDirectory(Files.java:700)
        at java.base/java.nio.file.Files.createAndCheckIsDirectory(Files.java:807)
        at java.base/java.nio.file.Files.createDirectories(Files.java:793)
        at jdk.jpackage/jdk.jpackage.internal.IOUtils$2.preVisitDirectory(IOUtils.java:119)
        at jdk.jpackage/jdk.jpackage.internal.IOUtils$2.preVisitDirectory(IOUtils.java:112)
        at java.base/java.nio.file.Files.walkFileTree(Files.java:2817)
        at java.base/java.nio.file.Files.walkFileTree(Files.java:2882)
        at jdk.jpackage/jdk.jpackage.internal.IOUtils.copyRecursive(IOUtils.java:112)
        at jdk.jpackage/jdk.jpackage.internal.IOUtils.copyRecursive(IOUtils.java:107)
        at jdk.jpackage/jdk.jpackage.internal.AbstractAppImageBuilder.copyApplication(AbstractAppImageBuilder.java:74)
        at jdk.jpackage/jdk.jpackage.internal.WindowsAppImageBuilder.prepareApplicationFiles(WindowsAppImageBuilder.java:103)
        at jdk.jpackage/jdk.jpackage.internal.AppImageBundler.createAppBundle(AppImageBundler.java:172)
        at jdk.jpackage/jdk.jpackage.internal.AppImageBundler.execute(AppImageBundler.java:91)
        ... 8 more

And the folder now looks like this

└───temp
    └───images
        ├───win-exe.image
        └───win-msi.image
            └───Test
                ├───app
                │   └───temp
                │       └───images
                │           ├───win-exe.image
                │           └───win-msi.image
                │               └───Test
                │                   └───app
                │                       └───temp
                │                           └───images
                │                               ├───win-exe.image
                │                               └───win-msi.image
                └───runtime
                    ├───bin
                    │   └───server
                    ├───conf
                    │   ├───management
                    │   └───security
                    │       └───policy
                    │           ├───limited
                    │           └───unlimited
                    ├───legal
                    │   ├───java.base
                    │   ├───java.compiler
                    │   ├───java.datatransfer
                    │   ├───java.desktop
                    │   ├───java.instrument
                    │   ├───java.logging
                    │   ├───java.management
                    │   ├───java.management.rmi
                    │   ├───java.naming
                    │   ├───java.net.http
                    │   ├───java.prefs
                    │   ├───java.rmi
                    │   ├───java.scripting
                    │   ├───java.security.jgss
                    │   ├───java.security.sasl
                    │   ├───java.smartcardio
                    │   ├───java.sql
                    │   ├───java.sql.rowset
                    │   ├───java.transaction.xa
                    │   ├───java.xml
                    │   ├───java.xml.crypto
                    │   ├───jdk.accessibility
                    │   ├───jdk.attach
                    │   ├───jdk.charsets
                    │   ├───jdk.compiler
                    │   ├───jdk.crypto.cryptoki
                    │   ├───jdk.crypto.ec
                    │   ├───jdk.crypto.mscapi
                    │   ├───jdk.dynalink
                    │   ├───jdk.editpad
                    │   ├───jdk.httpserver
                    │   ├───jdk.incubator.foreign
                    │   ├───jdk.incubator.vector
                    │   ├───jdk.internal.ed
                    │   ├───jdk.internal.jvmstat
                    │   ├───jdk.internal.le
                    │   ├───jdk.internal.opt
                    │   ├───jdk.jartool
                    │   ├───jdk.javadoc
                    │   ├───jdk.jconsole
                    │   ├───jdk.jdeps
                    │   ├───jdk.jdi
                    │   ├───jdk.jdwp.agent
                    │   ├───jdk.jfr
                    │   ├───jdk.jlink
                    │   ├───jdk.jpackage
                    │   ├───jdk.jshell
                    │   ├───jdk.jsobject
                    │   ├───jdk.jstatd
                    │   ├───jdk.localedata
                    │   ├───jdk.management
                    │   ├───jdk.management.agent
                    │   ├───jdk.management.jfr
                    │   ├───jdk.naming.dns
                    │   ├───jdk.naming.rmi
                    │   ├───jdk.net
                    │   ├───jdk.nio.mapmode
                    │   ├───jdk.random
                    │   ├───jdk.sctp
                    │   ├───jdk.security.auth
                    │   ├───jdk.security.jgss
                    │   ├───jdk.unsupported
                    │   ├───jdk.unsupported.desktop
                    │   ├───jdk.xml.dom
                    │   └───jdk.zipfs
                    └───lib
                        ├───jfr
                        └───security

Get no exe generated and can't delete the folder. I've been searching if someone had this problem but had no success so I posted it here. Thanks in advance for the help! If you need any more information about this just ask.

CodePudding user response:

It looks like you are using bad parameters which cause recursive copying. You have set --i and --temp such that input folder is current directory and therefore contains the temp folder - so jpackage is copying the current directory into temp every time.

Just create a directory for the important structure of your app and reference that independent folder say as --i myappstructure, then temp won't be a recursive copy into itself with --temp temp.

You don't need to use --temp parameter unless you wish to modify the release structure in-between jpackage app-image and exe invocations.

  • Related