这个命令是什么意思,执行什么功能?

What does this command mean and what functions performs?

this 教程中我读到了这个命令 - -Djava.awt.headless=true 从文本中我不明白这个命令的作用。在 Tomcat 的文档中我没有找到任何关于它的信息。我应该在哪里使用和输入?

如果执行以下命令:

java -h

可以看到java命令的帮助

你会发现:

[...]

-D<name>=<value> set a system property

[...]

所以这意味着您定义了一个新系统 属性,名称为 java.awt.headless,值为 true

您可以在 link 上找到与此变量 (java.awt.headless) 相关的一些附加信息,其中指出:

You can also use the following command line if you plan to run the same application in both a headless and a traditional environment:

java -Djava.awt.headless=true

注:

Headless mode is a system configuration in which the display device, keyboard, or mouse is lacking. Sounds unexpected, but actually you can perform different operations in this mode, even with graphic data.


在 tomcat 上设置系统属性。

如果你有tomcat7你可以编辑以下文件

<TOMCAT DIRECTORY>/conf/catalina.properties

并添加 属性 java.awt.headless。 tomcat 的其他版本也可以使用相同的文件来设置系统 属性。