我的问题是:是否有一种方法可以在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 !
这里是自动点击的代码:
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();
justOneClick(frame.getX()+100, frame.getY()+100);
}
catch(AWTException e)
{
e.printStackTrace();
}
简而言之,这是我的两个问题:
我每次想要在虚拟显示器上启动一个应用程序时仍需要调用xvfb-run。这意味着未由我启动的应用程序不会在虚拟显示器上启动。
我无法在由xvfb-run创建的显示器上启动另一个应用程序。
对于我的糟糕英语语法表示抱歉,感谢您的时间。