使用 java.exe 执行静默模式

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2902656/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-29 23:21:18  来源:igfitidea点击:

Silent mode execution with java.exe

javabackground-process

提问by srinannapa

I would like to know if there is a way to execute the "java.exe" as a background process (silent mode execution)

我想知道是否有办法将“java.exe”作为后台进程执行(静默模式执行)

Ex: java -cp . MyClass arg1

例如: java -cp 。我的类 arg1

I want to run the above statement as a background process , without opening command window

我想在不打开命令窗口的情况下将上述语句作为后台进程运行

回答by paxdiablo

Under Windows, use javaw.exeinstead of java.exe. See herefor link, relevant bit copied here:

在 Windows 下,使用javaw.exe代替java.exe. 请参阅此处获取链接,此处复制了相关位:

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

javaw命令与 相同java,只是javaw没有关联的控制台窗口。使用javaw时,你不想要一个命令提示符窗口出现。该javaw发射器将,但是,如果启动由于某种原因失败,则显示错误信息的对话框。

回答by Andreas Dolk

Use

利用

javaw -cp . MyClass arg1

(assuming you're on MS windows)

(假设您使用的是 MS Windows)

If you're looking at services rather then applications then have a look at 'service wrappers'

如果您正在查看服务而不是应用程序,那么请查看“服务包装器”