从使用Inno Setup和maven创建的本机javafx应用程序写入控制台 [英] Write to console from a native javafx app created with Inno Setup and maven

查看:1720
本文介绍了从使用Inno Setup和maven创建的本机javafx应用程序写入控制台的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个JavaFX应用程式,而且我使用的是maven外挂程式 javafx-maven -plugin 创建应用程序包(Windows中的app.exe,使用Inno Setup生成)。



应用程序在提供参数时以控制台模式运行。



问题是,在控制台模式下运行时,我看不到打印到控制台的消息。消息(使用System.out.println编写)不会显示在Windows控制台中。但它们是生成的,因为如果我将输出重定向到一个文件(app.exe> out.txt),该文件包含所有消息。



我试图运行.exe与cygwin甚至在Linux中编译整个项目,在这两个输出正确显示在控制台中。所以问题似乎只有当运行javafx exe与Windows控制台(cmd)。我猜stdout被重定向到某个地方。 首先:感谢您使用javafx-maven-maven-2.0版本,



短版本: strong>你不能做太多



长版本:
问题来自JDK的本机启动器,没有与InnoSetup,也不是Maven。



引用源代码本身这是会发生什么:



基本方法:
- Launcher可执行文件加载packager.dll / libpackager.dylib / libpackager.so并调用下面的start_launcher。
- 读应用程序启动配置的app / package.cfg或Info.plist或app /< appname> .cfg
(package.cfg是属性文件)。
- 使用请求的JVM设置(绑定的客户端JVM(如果可用),服务器或已安装的JVM)加载JVM。
- 等待JVM退出并退出Main
- 通过set env变量(TODO)调试应用程序或在命令行中传递/ Debug选项。
- TODO:默认目录设置为用户的文档和设置。
- 应用程序文件夹添加到库路径(因此LoadLibrary())工作。

在发射器中挖出一点后,如果找到点,其中STD - 检索输出,其被编译,因为在Windows系统上USE_JLI_LAUNCH未设置。这真正的问题是只附加控制台编写器的条件使用DEBUG标志编译



这可能是一个bug / fluke在JDK本身,我会尝试找到的东西,并可能将其作为bug在oracle-bug-tracker。



编辑: / strong>经过一些进一步挖掘,有一些我发现有趣的:生成的EXE文件是一个简单的Windows可执行文件,没有cli可执行

解决方法:创建/编译自己的文件使用一些重定向的原生启动文件,如下所示:



在Windows中将cout重定向到控制台



https://bobobobo.wordpress.com/2009/03/01/如何附加控制台到您的应用程序在c /


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 console mode when arguments are given.

The problem is that when running in console mode, I can't see the mesages printed to console. The messages (written with System.out.println) don't appear in the Windows console. But they are generated, because if I redirect the output to a file (app.exe > out.txt) the file contains all the messages.

I have tried to run the .exe with cygwin and even compiled the whole project in Linux, and in both of them the output is correctly displayed in the console. So the problem seems to be only when running the javafx exe with the Windows console (cmd). I guess the stdout is redirected to somewhere. How can I change this?

解决方案

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/<appname>.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/

这篇关于从使用Inno Setup和maven创建的本机javafx应用程序写入控制台的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆