有没有办法从 Java 程序中隐藏 win32 启动控制台(如果可能没有 JNI)

2022-01-11 00:00:00 console winapi java

您从控制台启动一个 java 程序(可能使用 .bat 脚本).我不想让控制台保持可见,我想隐藏它.

You launch a java program from a console (maybe using a .bat script). I don't want the console to remain visible, I want to hide it.

有没有简单的方法来做到这一点?没有 JNI 吗?

Is there a simple way to do this ? Without JNI ?

推荐答案

使用javaw.

http://java.sun.com/javase/6/docs/tooldocs/windows/java.html

javaw 命令与 java 相同,只是 javaw 没有关联的控制台窗口.当您不希望出现命令提示符窗口时,请使用 javaw.但是,如果由于某种原因启动失败,javaw 启动器将显示一个包含错误信息的对话框.

The javaw command is identical to java, except that with javaw there is no associated console window. Use javaw when you don't want a command prompt window to appear. The javaw launcher will, however, display a dialog box with error information if a launch fails for some reason.

相关文章