简体   繁体   English

如何在没有 GUI 的情况下运行 Java(isHeadless 是真的)?

[英]How can I run Java without GUI (where isHeadless is true)?

I guess many people think this question has duplicated ones.我想很多人认为这个问题有重复的问题。 However, this question precisely asks然而,这个问题恰恰问

how can I run Java where !GraphicsEnvironment.isHeadless() returns true我如何在!GraphicsEnvironment.isHeadless()返回true地方运行 Java

The answer would be like答案是这样的

java --gui=disabled -jar hoge.jar

The commandline parameter -Djava.awt.headless=true can be used to set the headless mode from the commandline.命令行参数-Djava.awt.headless=true可用于-Djava.awt.headless=true设置无头模式。

The linked question shows ways to set it programmatically, which is somewhat trickier but may be preferrable if you don't want or can't access the commandline parameters. 链接的问题显示了以编程方式设置它的方法,这有点棘手,但如果您不想或无法访问命令行参数,则可能更可取。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM