<!DOCTYPE html>
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    Hi John,<br>
    thanks for the answer.<br>
    <br>
    The problem happen even with other JDKs like the Azul, corretto...<br>
    <br>
    The weird thing is that to reproduce it you need to package the
    program with jpackage and then execute the program using the
    generated exe.<br>
    <br>
    This is the only code needed to reproduce the issue.<br>
    <br>
    <pre
style="box-sizing: border-box; overflow: auto; font-family: "Helvetica Neue", "Segoe UI", Arial, sans-serif-regular; font-size: 14px; display: block; padding: 9.5px; margin: 0px 0px 10px; line-height: 1.42857; color: rgb(51, 51, 51); word-break: break-all; overflow-wrap: break-word; background-color: rgb(255, 255, 255); white-space: pre-wrap; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">public static void main(String... args) throws IOException {
        String[] cmdToRunUsingArgs = {"cmd.exe", "/C", "C:\\Program Files\\Notepad++\\notepad++.exe"};
        Runtime.getRuntime().exec(cmdToRunUsingArgs);
        Executors.newSingleThreadScheduledExecutor().schedule(() -> {
            System.exit(0);
        }, 30, TimeUnit.SECONDS);
    }</pre>
    <br>
    It's very weird because the problem does not happen with the
    previous minor version of the JDK21, the JDK 21.01_12.<br>
    <br>
    I'm pretty sure now that this isn't related to JavaFX since the
    problem can be reproduced even without JavaFX.<br>
    <br>
    Problem must be in the JPackage.<br>
    <br>
    Thanks<br>
    Davide<br>
    <br>
    <br>
    <br>
    Il 04/02/2024 18:17, John Hendrikx ha scritto:<br>
    <blockquote type="cite"
      cite="mid:56bf5b6a-f76d-5a0b-1c21-ba1ed693eb9d@gmail.com">
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
      <p>Hi, <br>
      </p>
      <p>Does that Temurin build contain JavaFX, or is it just a new
        Temurin build?  Did you change anything else besides the JDK
        used?  You could try other JDK's (openjdk, corretto, etc) as
        well.<br>
      </p>
      <p>Is there anything being logged that may indicate what went
        wrong?</p>
      <p>That all said, it seems really unlikely this is related to
        JavaFX.  <br>
      </p>
      <p>If System.exit(0) is killing both the new and old application,
        then it wasn't really spawned independently, so you can look
        into that (you could put a delay there, and see with a tool like
        `top` or Task Manager says, and see whether the restarted app is
        a child process or not).</p>
      <p>It's also possible the problem is in the tools/settings used to
        create the ".exe", so see if you changed anything there.<br>
      </p>
      <p>For more info, tips or other ways of doing restarts:
        <a class="moz-txt-link-freetext"
href="https://stackoverflow.com/questions/4159802/how-can-i-restart-a-java-application"
          moz-do-not-send="true">https://stackoverflow.com/questions/4159802/how-can-i-restart-a-java-application</a></p>
      <p>--John<br>
      </p>
      <p><br>
      </p>
      <div class="moz-cite-prefix">On 04/02/2024 02:49, Davide Perini
        wrote:<br>
      </div>
      <blockquote type="cite"
        cite="mid:25283849-f1ec-4036-b857-21f75e6bfafd@dpsoftware.org">
        <meta http-equiv="content-type"
          content="text/html; charset=UTF-8">
        Hi there,<br>
        my JavaFX 21.0.2 app experienced a very weird regression when
        switching from Temurin<br>
        OpenJDK21U-jdk_x64_windows_hotspot_21.0.1_12<br>
        to<br>
        OpenJDK21U-jdk_x64_windows_hotspot_21.0.2_13<br>
        <br>
        I use this method to restart my app.<br>
        <br>
        <div style="background-color:#1e1f22;color:#bcbec4">
          <pre
style="font-family:'JetBrains Mono',monospace;font-size:9,8pt;"><span
          style="color:#cf8e6d;">public void </span><span
          style="color:#56a8f5;">restart</span>() {
    // path to my exe app plus one string argument
    String[] cmdToRunUsingArgs = {<span style="color:#6aab73;">"C:\Users\sblantipodi\AppData\Local\Firefly Luciferin\Firefly Luciferin.exe"</span>,<span
          style="color:#6aab73;"> "string argument"</span>};
    <span style="color:#cf8e6d;">try </span>{
        Runtime.<span style="font-style:italic;">getRuntime</span>().exec(cmdToRunUsingArgs);
    } <span style="color:#cf8e6d;">catch </span>(SecurityException | IOException e) {
        <span style="color:#c77dbb;font-style:italic;">log</span>.error(e.getMessage());
    }
    javafx.application.Platform.<span style="font-style:italic;">exit</span>();
    System.<span style="font-style:italic;">exit</span>(<span
          style="color:#2aacb8;">0</span>);
}</pre>
        </div>
        <br>
        It worked well since years until JDK 21.0.2_13.<br>
        If I revert back to 21.0.1_12 it works well.<br>
        <br>
        That method should start a new instance of the app, and close
        the "old instance".<br>
        <br>
        With JDK 21.0.2_13, it closed the running instance but does not
        open a new instance.<br>
        <br>
        I don't know if open a bugreport to JDK but before opening the
        bug report I would like to ask you if that method to restart the
        app is correct or if you think that I can use a better way.<br>
        <br>
        Thanks<br>
        Davide<br>
        <br>
        <br>
        <br>
        <br>
        <br>
        <br>
      </blockquote>
    </blockquote>
    <br>
  </body>
</html>