我的问题是:有没有办法在Linux服务器上设置虚拟显示作为默认显示(如果没有计数器指示,所有启动的GUI应用程序将显示在该显示器上)?
我尝试使用这个:xvfb-run java -jar autoclick.jar,它产生以下输出:
searching graphic devices
is Headless:false
screen N°1 width:1600 height:900
just 1 robot click:
Magic button clicked !
Run Code Online (Sandbox Code Playgroud)
这是自动代码:
System.out.println("searching graphic devices");
System.out.println("is Headless:"+GraphicsEnvironment.isHeadless());
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
int count = 1;
for(GraphicsDevice screen : ge.getScreenDevices())
{
System.out.println("screen N°"+count+" width:"+screen.getDisplayMode().getWidth()
+" height:"+screen.getDisplayMode().getHeight());
}
{... create a JFrame and add a JButton that closes the application and prints a message to the console when clicked}
System.out.println("just 1 robot click:");
try
{
robot = new Robot(); …Run Code Online (Sandbox Code Playgroud)