Write to console from a native javafx app created with Inno Setup and maven

后端 未结 1 636
南旧
南旧 2020-12-11 12:28

I have a JavaFX app, and I am using the maven plugin javafx-maven-plugin to create an app bundle (app.exe in Windows, generated with Inno Setup).

The app runs in con

1条回答
  •  醉梦人生
    2020-12-11 13:25

    First of all: thanks for using the javafx-maven-plugin, I'm the maintainer of that maven-plugin.

    short version: you can't do very much

    long version: The problem comes with the native launcher of the JDK and has nothing todo with InnoSetup, nor Maven.

    Quoting the source-code itself this is what happens:

    Basic approach:
      - Launcher executable loads packager.dll/libpackager.dylib/libpackager.so and calls start_launcher below.
      - Reads app/package.cfg or Info.plist or app/.cfg for application launch configuration
         (package.cfg is property file).
      - Load JVM with requested JVM settings (bundled client JVM if availble, server or installed JVM otherwise).
      - Wait for JVM to exit and then exit from Main
      - To debug application by set env variable (TODO) or pass "/Debug" option on command line.
      - TODO: default directory is set to user's Documents and Settings.
      - Application folder is added to the library path (so LoadLibrary()) works.
    

    After digging a bit inside the launcher, if found the spot, where the STD-output is retrieved, which gets compiled, because on windows-systems "USE_JLI_LAUNCH" is not set. The real problem with this comes with the condition to only append that console-writer when being compiled with DEBUG-flag

    It might be a bug/fluke within the JDK itself, I'll try to find something and might file that as bug on oracle-bug-tracker.

    EDIT: after some further digging, there is something I found interesting: the generated EXE-file is a simple windows-executable, no cli-executable as seen in the launcher-source-code, that is the reason you dont see any console-output but having the result when pipelining into some file.

    Workaround: create/compile your own native launcher-file using some redirects as described here:

    Redirecting cout to a console in windows

    https://bobobobo.wordpress.com/2009/03/01/how-to-attach-a-console-to-your-gui-app-in-c/

    0 讨论(0)
提交回复
热议问题