Re: RFR: 8325203: System.exit(0) kills the launched 3rd party application
On Thu, 8 Feb 2024 21:03:26 GMT, Alexey Semenyuk wrote: >> Tested with the use case from the CR. >> >> The idea of the fix is to prevent grandchildren processes from being >> automatically attached to the job killing all processes attached to it when >> the job object is destroyed. >> >> Filed a follow-up https://bugs.openjdk.org/browse/JDK-8325525 CR to track >> adding a jtreg test for the issue. > > @sashamatveev please review @alexeysemenyukoracle sorry if I quote you. Do you know how the release cycle works here? Will we see this fix in the next JDK21 release? thanks for your work and for the fix :) - PR Comment: https://git.openjdk.org/jdk/pull/17779#issuecomment-1978380017
JPackage does very weird things and it doesn't work with SNAP
Hi there... I have a JDK23 app that is packaged with jpackage. I am running this app in Snapcraft. It works well but I cannot restart it for a very weird problem. When I try to restart it with a simple code like this: ``` ArrayList cmdOutput = new ArrayList<>(); try { **_ProcessBuilder processBuilder = new ProcessBuilder("/bin/sh", "-c", "/snap/myappid/bin/myappbinarygeneratedwithjpackage");_** Process process = processBuilder.start(); if (waitForOutput > 0) { if (process.waitFor(waitForOutput, TimeUnit.MILLISECONDS)) { int exitCode = process.exitValue(); log.info("Exit code: {}", exitCode); BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream())); String line; while ((line = reader.readLine()) != null) { log.info(line); } BufferedReader errorReader = new BufferedReader(new InputStreamReader(process.getErrorStream())); while ((line = errorReader.readLine()) != null) { log.error(line); } } else { log.error("The command has exceeded the time limit and has been terminated."); process.destroy(); } } } catch (Exception e) { log.error(e.getMessage()); } ``` This simple code should run new ProcessBuilder("/bin/sh", "-c", "/snap/myappid/bin/myappbinarygeneratedwithjpackage"); If I execute this code when running native, it works well and it spawn another instance of my app. if I execute this code inside a snap environment, the code return an exit code 1 and it return this output: ``` Usage: java [options] [args...] (to execute a class) or java [options] -jar [args...] (to execute a jar file) or java [options] -m [/] [args...] java [options] --module [/] [args...] (to execute the main class in a module) or java [options] [args] (to execute a source-file program) Arguments following the main class, source file, -jar , -m or --module / are passed as the arguments to main class. where options include: -cp -classpath --class-path A : separated list of directories, JAR archives, and ZIP archives to search for class files. -p --module-path ... A : separated list of elements, each element is a file path to a module or a directory containing modules. Each module is either a modular JAR or an exploded-module directory. --upgrade-module-path ... A : separated list of elements, each element is a file path to a module or a directory containing modules to replace upgradeable modules in the runtime image. Each module is either a modular JAR or an exploded-module directory. --add-modules [,...] root modules to resolve in addition to the initial module. can also be ALL-DEFAULT, ALL-SYSTEM, ALL-MODULE-PATH. --enable-native-access [,...] allow code in modules to access code and data outside the Java runtime. can also be ALL-UNNAMED to indicate code on the class path. --list-modules list observable modules and exit -d --describe-module describe a module and exit --dry-run create VM and load main class but do not execute main method. The --dry-run option may be useful for validating the command-line options such as the module system configuration. --validate-modules validate all modules and exit The --validate-modules option may be useful for finding conflicts and other errors with modules on the module path. -D= set a system property -verbose:[class|module|gc|jni] enable verbose output for the given subsystem -version print product version to the error stream and exit --version print product version to the output stream and exit -showversion print product version to the error stream and continue --show-version print product version to the output stream and continue --show-module-resolution show module resolution output during startup -? -h -help print this help message to the error stream --help print this help message to the output stream -X print help on extra options to the error stream --help-extra print help on extra options to the output stream -ea[:...|:] -enableassertions[:...|:]
Re: JPackage does very weird things and it doesn't work with SNAP
Apart this, in the current state I think jpackage is simply not suited to be used in conjunction with snaps and strictly confined containers because it simply don't do what is supposed to do. launching a jpackaged app and get the java command output is something clearly broken from the jpackage side. is there someone interested in making jpackaged apps functional with snap? On 09/12/2024 06:14, David Holmes wrote: On 9/12/2024 1:21 pm, David Alayachew wrote: > If it's one of the expected ones, things will proceed normally. There are expected segfaults in libjvm? Sorry, I am 100% ignorant about this subject. I just wanted to know if that was the intended meaning. Yes there is a deliberate segfault during VM startup to check AVX register save/restore behaviour. An optional one (non-product) for APX register save/restore behaviour. David - On Sun, Dec 8, 2024, 3:46 PM Kim Barrett <mailto:kim.barr...@oracle.com>> wrote: On 12/8/24 1:56 PM, Davide Perini wrote: > I tried attaching gdb, but it’s clear that jvm doesn’t like debuggers > attached. Right from the start it got sigstop handlers invoked, and > then a segfault in libjvm. I can't comment on the rest of your message, but I might be able to help with this. The JVM sometimes executes code that may trigger signals that are expected to be handled by the JVM's signal handler. In particular, I know there are a couple of these early in startup. Just try continuing in the debugger, and let the JVM's signal handler have a crack at them. If it's one of the expected ones, things will proceed normally.
Re: JPackage does very weird things and it doesn't work with SNAP
Hi, thanks for the answer, I really appreciate it. I tried adding the JPACKAGE_DEBUG env variable but didn't changed the output. When I run the binary generated by jpackage in the snap sandbox I get the "java" command output as output. This does not happen on flatpak. Do you know if jpackage uses "additional env variables" that must be correctly set? I noticed that the cfg uses an $APPDIR env variable and that env variable is correctly set with the path of the jar, is there other env variables to set to make it work? I add a bit of context. I'm using a deb package generated with jpackage and extracted with the "ar x" command, once extracted, I use the binary inside the bin folder to launch my app. The app starts without problems but then it can't be restarted within the app by using the same binary. Any ideas on what the problem might be? Thanks On 09/12/24 20:05, Alexey Semenyuk wrote: Hi Davide, An app launcher generated by jpackage runs `rpm` and `dpkg` queries to detect the package that owns it. Why does it need to know the name of the package? The app launcher needs to locate the corresponding ".cfg" (.cfg) file in the app image to read the startup configuration. If you configure jpackage to create a package installed in "/usr" tree instead of the default "/opt" it will create a different app image layout. This makes it impossible to hard-code the location of the ".cfg" file in the app launcher. Instead, the app launcher finds the ".cfg" file in the list of files of the package it belongs to. When the app launcher is launched, it doesn't know the type of the owner package (rpm or deb) or its name; it detects these details at runtime. That is why it runs `rpm` and `dpkg` queries at startup. Try running your app with JPACKAGE_DEBUG env variable set to "true": &> env JPACKAGE_DEBUG=true ... It logs the launcher's activity, which can give a clue as to what is going on. - Alexey On 12/8/2024 1:56 PM, Davide Perini wrote: Hi there... I have a JDK23 app that is packaged with jpackage. I am running this app in Snapcraft. It works well but I cannot restart it for a very weird problem. When I try to restart it with a simple code like this: ``` ArrayList cmdOutput = new ArrayList<>(); try { **_ProcessBuilder processBuilder = new ProcessBuilder("/bin/sh", "-c", "/snap/myappid/bin/myappbinarygeneratedwithjpackage");_** Process process = processBuilder.start(); if (waitForOutput > 0) { if (process.waitFor(waitForOutput, TimeUnit.MILLISECONDS)) { int exitCode = process.exitValue(); log.info("Exit code: {}", exitCode); BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream())); String line; while ((line = reader.readLine()) != null) { log.info(line); } BufferedReader errorReader = new BufferedReader(new InputStreamReader(process.getErrorStream())); while ((line = errorReader.readLine()) != null) { log.error(line); } } else { log.error("The command has exceeded the time limit and has been terminated."); process.destroy(); } } } catch (Exception e) { log.error(e.getMessage()); } ``` This simple code should run new ProcessBuilder("/bin/sh", "-c", "/snap/myappid/bin/myappbinarygeneratedwithjpackage"); If I execute this code when running native, it works well and it spawn another instance of my app. if I execute this code inside a snap environment, the code return an exit code 1 and it return this output: ``` Usage: java [options] [args...] (to execute a class) or java [options] -jar [args...] (to execute a jar file) or java [options] -m [/] [args...] java [options] --module [/] [args...] (to execute the main class in a module) or java [options] [args] (to execute a source-file program) Arguments following the main class, source file, -jar , -m or --module / are passed as the arguments to main class. where options include: -cp -classpath --class-path A : separated list of directories, JAR archives, and ZIP archives to search for class files. -p --module-path ... A : separated list of elements, each element is a file path to a module or a directory containing modules. Each module is either a modular JAR or an exploded-module directory.
Will jpackage support WixTools v4 or v5 with Java 24?
As subject. Current wix v3 is deprecated. Will jpackage support WixTools v4 or v5 with Java 24? Thanks
Re: Will jpackage support WixTools v4 or v5 with Java 24?
Hi Kevin, I really, really appreciate your work here. Thanks for all the "light" you bring on the Java channels. Davide On 2024-12-11 21:31, Kevin Rushforth wrote: Yes, jpackage will support either v4 or v5 as of JDK 24: https://bugs.openjdk.org/browse/JDK-8319457 You can also see this in the early access release notes: https://jdk.java.net/24/release-notes (bottom of the page) -- Kevin On 12/11/2024 12:28 PM, Davide Perini wrote: As subject. Current wix v3 is deprecated. Will jpackage support WixTools v4 or v5 with Java 24? Thanks
Re: [External] : Re: JPackage does very weird things and it doesn't work with SNAP
You got the point and solved the problem I was hitting for days in 1 minutes. I simply added this env variable to my snapcraft.yaml LD_LIBRARY_PATH: $APPDIR:$LD_LIBRARY_PATH and this fixed it :) It reminds me this story: A man took his watch to a watchmaker for repair. The watchmaker examined it for a moment, gave it a gentle tap, and it started working perfectly. When the man asked for the bill, he was shocked to see it was quite high. The man exclaimed, "But it took you just a moment to fix it!" The watchmaker replied, "The tap cost you $1. Knowing where to tap is $99." ahah. Thank you Alexey, very appreciated. Davide On 11/12/24 22:09, Alexey Semenyuk wrote: Davide, Can you run the launcher with JPACKAGE_DEBUG env variable set to "true" on flatpak or anywhere else where it works? It should make the launcher print log messages to stdout. On Linux launcher's behavior depends on "LD_LIBRARY_PATH", "_JPACKAGE_LAUNCHER" env variables, see [1]. Launcher uses a dynamic library written in C++ to locate config files and set up arguments for launching JVM. This library must not be in the process where JVM runs. To achieve this the launcher loads the library in forked child process and collects initialization data it outputs through the pipe. See [2] for details. $APPDIR is not an env variable, its is a token the launcher replaces in config file at runtime. You can use "ar x" to run your app without installing a deb package, or you can use jpackage to create app directory instead of creating a native (deb) package. The launcher will be the same, so this will not address the issue you are experiencing; it will just simplify the debugging process. [1] https://github.com/openjdk/jdk/blob/master/src/jdk.jpackage/linux/native/libapplauncher/LinuxLauncherLib.cpp [2] https://github.com/openjdk/jdk/blob/master/src/jdk.jpackage/linux/native/applauncher/LinuxLauncher.c - Alexey On 12/11/2024 2:46 PM, Davide Perini wrote: Hi, thanks for the answer, I really appreciate it. I tried adding the JPACKAGE_DEBUG env variable but didn't changed the output. When I run the binary generated by jpackage in the snap sandbox I get the "java" command output as output. This does not happen on flatpak. Do you know if jpackage uses "additional env variables" that must be correctly set? I noticed that the cfg uses an $APPDIR env variable and that env variable is correctly set with the path of the jar, is there other env variables to set to make it work? I add a bit of context. I'm using a deb package generated with jpackage and extracted with the "ar x" command, once extracted, I use the binary inside the bin folder to launch my app. The app starts without problems but then it can't be restarted within the app by using the same binary. Any ideas on what the problem might be? Thanks On 09/12/24 20:05, Alexey Semenyuk wrote: Hi Davide, An app launcher generated by jpackage runs `rpm` and `dpkg` queries to detect the package that owns it. Why does it need to know the name of the package? The app launcher needs to locate the corresponding ".cfg" (.cfg) file in the app image to read the startup configuration. If you configure jpackage to create a package installed in "/usr" tree instead of the default "/opt" it will create a different app image layout. This makes it impossible to hard-code the location of the ".cfg" file in the app launcher. Instead, the app launcher finds the ".cfg" file in the list of files of the package it belongs to. When the app launcher is launched, it doesn't know the type of the owner package (rpm or deb) or its name; it detects these details at runtime. That is why it runs `rpm` and `dpkg` queries at startup. Try running your app with JPACKAGE_DEBUG env variable set to "true": &> env JPACKAGE_DEBUG=true ... It logs the launcher's activity, which can give a clue as to what is going on. - Alexey On 12/8/2024 1:56 PM, Davide Perini wrote: Hi there... I have a JDK23 app that is packaged with jpackage. I am running this app in Snapcraft. It works well but I cannot restart it for a very weird problem. When I try to restart it with a simple code like this: ``` ArrayList cmdOutput = new ArrayList<>(); try { **_ProcessBuilder processBuilder = new ProcessBuilder("/bin/sh", "-c", "/snap/myappid/bin/myappbinarygeneratedwithjpackage");_** Process process = processBuilder.start(); if (waitForOutput > 0) { if (process.waitFor(waitForOutput, TimeUnit.MILLISECONDS)) { int exitCode = process.exitValue(); log.info("Exit code: {}", exitCode); BufferedReader reader = new BufferedReader(new Input
jpackage and dependencies...
Hi all, is it normal that the .deb files created with jpackage "knows something" about OS dependencies? Some of my users are complaining that my deb files uses some deps... sudo dpkg -i FireflyLuciferinLinux.deb . dpkg: dependency problems prevent configuration of fireflyluciferin: fireflyluciferin depends on libasound2t64; however: Package libasound2t64 is not installed. This is something new for me. Is jpackage able to know what are the needed deps of my app? Can I configure this behaviour? Thanks Davide
Re: jpackage and Wix 5
I add some context: I installed wix 5 using the donet command globally, wix is in the path but when I try to run my jpackage command I get this error: jpackage -i ./target --type exe --main-class org.dpsoftware.JavaFXStarter --main-jar FireflyLuciferin-jar-with-dependencies.jar --icon ./data/img/luciferin_logo.ico --win-menu --win-menu-group Ambilight --copyright "Davide Perini" --name "Firefly Luciferin" --vendor DPsoftware --win-dir-chooser --win-shortcut --win-per-user-install --win-shortcut --win-shortcut-prompt --java-options "-XX:+UseZGC -Xms64m -Xmx1024m" java.io.IOException: Command [wix.exe, build, -nologo, -pdbtype, none, -intermediatefolder, C:\Users\SBLANT~1\AppData\Local\Temp\jdk.jpackage95160440034084538\wixobj, -ext, WixToolset.Util.wixext, -arch, x64, -ext, WixToolset.UI .wixext, -b, C:\Users\SBLANT~1\AppData\Local\Temp\jdk.jpackage95160440034084538\config, -loc, C:\Users\SBLANT~1\AppData\Local\Temp\jdk.jpackage95160440034084538\config\MsiInstallerStrings_de.wxl, -loc, C:\Users\SBLANT~1\AppData\ Local\Temp\jdk.jpackage95160440034084538\config\MsiInstallerStrings_en.wxl, -loc, C:\Users\SBLANT~1\AppData\Local\Temp\jdk.jpackage95160440034084538\config\MsiInstallerStrings_ja.wxl, -loc, C:\Users\SBLANT~1\AppData\Local\Temp\j dk.jpackage95160440034084538\config\MsiInstallerStrings_zh_CN.wxl, -culture, en-us, -d, JpAppDescription=Firefly Luciferin, -d, JpStartMenuShortcutPrompt=yes, -d, JpDesktopShortcutPrompt=yes, -d, JpProductCode=e0be8901-8911-3da4 -83e2-2c15892e1623, -d, JpAppName=Firefly Luciferin, -d, JpAllowDowngrades=yes, -d, JpIcon=C:\Users\SBLANT~1\AppData\Local\Temp\jdk.jpackage95160440034084538\images\win-msi.image\Firefly Luciferin\Firefly Luciferin.exe, -d, JpAp pSizeKb=409283, -d, JpAppVersion=1.0, -d, JpAfterInstallDirDlg=ShortcutPromptDlg, -d, JpAllowUpgrades=yes, -d, JpProductUpgradeCode=2b8902a1-d85a-3650-9b08-d990b365e5e9, -d, JpAppVendor=DPsoftware, -d, JpConfigDir=C:\Users\SBLAN T~1\AppData\Local\Temp\jdk.jpackage95160440034084538\config, C:\Users\SBLANT~1\AppData\Local\Temp\jdk.jpackage95160440034084538\config\main.wxs, C:\Users\SBLANT~1\AppData\Local\Temp\jdk.jpackage95160440034084538\config\bundle.wx f, C:\Users\SBLANT~1\AppData\Local\Temp\jdk.jpackage95160440034084538\config\ui.wxf, C:\Users\SBLANT~1\AppData\Local\Temp\jdk.jpackage95160440034084538\config\ShortcutPromptDlg.wxs, C:\Users\SBLANT~1\AppData\Local\Temp\jdk.jpack age95160440034084538\config\InstallDirNotEmptyDlg.wxs, -out, C:\Users\SBLANT~1\AppData\Local\Temp\jdk.jpackage95160440034084538\wixobj\a.msi] in C:\Users\SBLANT~1\AppData\Local\Temp\jdk.jpackage95160440034084538\images\win-msi.image\Firefly Luciferin exited with 144 code Il 19/03/2025 10:12, Davide Perini ha scritto: Hi there, I'm using jpackage along with Wix3. The command I use to generate my .exe is: jpackage -i ../../target --type exe --main-class org.dpsoftware.JavaFXStarter --main-jar FireflyLuciferin-jar-with-dependencies.jar --icon ../../data/img/java_fast_screen_capture_logo.ico --win-menu --win-menu-group Luciferin --copyright "Davide Perini" --name "Firefly Luciferin" --vendor DPsoftware --win-dir-chooser --win-shortcut --win-per-user-install --win-upgrade-uuid myuuid --app-version "${{steps.get-id.outputs.id}}" --win-shortcut --win-shortcut-prompt --java-options "-XX:+UseZGC -XX:+UseStringDeduplication -Xms64m -Xmx1024m --add-modules=jdk.incubator.vector" How can I move it to Wix5 using Java 24? Is there a guide/documentation that help in migrating from Wix 3 to Wix 5? Thanks Davide
jpackage and Wix 5
Hi there, I'm using jpackage along with Wix3. The command I use to generate my .exe is: jpackage -i ../../target --type exe --main-class org.dpsoftware.JavaFXStarter --main-jar FireflyLuciferin-jar-with-dependencies.jar --icon ../../data/img/java_fast_screen_capture_logo.ico --win-menu --win-menu-group Luciferin --copyright "Davide Perini" --name "Firefly Luciferin" --vendor DPsoftware --win-dir-chooser --win-shortcut --win-per-user-install --win-upgrade-uuid myuuid --app-version "${{steps.get-id.outputs.id}}" --win-shortcut --win-shortcut-prompt --java-options "-XX:+UseZGC -XX:+UseStringDeduplication -Xms64m -Xmx1024m --add-modules=jdk.incubator.vector" How can I move it to Wix5 using Java 24? Is there a guide/documentation that help in migrating from Wix 3 to Wix 5? Thanks Davide
Using jpackage 24 with WiX Toolset 5 or 6, how can I start the app automatically after installation is complete?
As subject. Using jpackage 24 with WiX Toolset 5 or 6, how can I start the app automatically after installation is complete? As title, is this possible? At the moment I generate my installer with this command: jpackage -i target --type exe --main-class org.dpsoftware.JavaFXStarter --main-jar FireflyLuciferin-jar-with-dependencies.jar --win-menu --win-menu-group Luciferin --copyright "Davide Perini" --name "Firefly Luciferin" --vendor DPsoftware --win-dir-chooser --win-shortcut --win-per-user-install --win-upgrade-uuid 33c82dc4-e0e0-11ea-87d0-0242ac130003 --app-version "0.0.5" --win-shortcut --win-shortcut-prompt --java-options "-XX:+UseZGC -XX:+UseStringDeduplication -Xms64m -Xmx1024m" How can I customize the installer to launch the application once the installation is finished? Thanks Davide