Java AWT 需要 X11,如何使用 xvfb (ubuntu 14.04)

Java AWT requires X11 , how to use xvfb (ubuntu 14.04)

我有一个 java 应用程序需要 X11 DISPLAY 变量, 我得到的例外是:

    Caused by: java.awt.HeadlessException:
No X11 DISPLAY variable was set, but this program performed an operation which requires it.
        at java.awt.GraphicsEnvironment.checkHeadless(GraphicsEnvironment.java:204)
        at java.awt.Window.<init>(Window.java:536)
        at java.awt.Frame.<init>(Frame.java:420)

我已经在 ubuntu 机器上安装了 Xvfb:

root      1470  1469  0 02:40 pts/3    00:00:00 Xvfb :1 -screen 0 1152x900x8

但我仍然收到此错误。

当我启动 Xvfb 时,我收到以下响应:

Initializing built-in extension Generic Event Extension
Initializing built-in extension SHAPE
Initializing built-in extension MIT-SHM
Initializing built-in extension XInputExtension
Initializing built-in extension XTEST
Initializing built-in extension BIG-REQUESTS
Initializing built-in extension SYNC
Initializing built-in extension XKEYBOARD
Initializing built-in extension XC-MISC
Initializing built-in extension SECURITY
Initializing built-in extension XINERAMA
Initializing built-in extension XFIXES
Initializing built-in extension RENDER
Initializing built-in extension RANDR
Initializing built-in extension COMPOSITE
Initializing built-in extension DAMAGE
Initializing built-in extension MIT-SCREEN-SAVER
Initializing built-in extension DOUBLE-BUFFER
Initializing built-in extension RECORD
Initializing built-in extension DPMS
Initializing built-in extension Present
Initializing built-in extension DRI3
Initializing built-in extension X-Resource
Initializing built-in extension XVideo
Initializing built-in extension XVideo-MotionCompensation
Initializing built-in extension SELinux
Initializing built-in extension GLX
[dix] Could not init font path element /usr/share/fonts/X11/cyrillic, removing from list!
[dix] Could not init font path element /usr/share/fonts/X11/100dpi/:unscaled, removing from list!
[dix] Could not init font path element /usr/share/fonts/X11/75dpi/:unscaled, removing from list!
[dix] Could not init font path element /usr/share/fonts/X11/Type1, removing from list!
[dix] Could not init font path element /usr/share/fonts/X11/100dpi, removing from list!
[dix] Could not init font path element /usr/share/fonts/X11/75dpi, removing from list!

而且它没有 return 返回给我,所以我按 'CTRL + C' 收回控制权,但是在查看 'ps aux | grep Xvfb' 之后我可以看到进程是 运行, 所以我不确定它是否有效。

如有任何帮助,我们将不胜感激。

谢谢

您没有收到错误,这些是关于旧字体的警告消息。在后台启动虚拟 X 服务器 (and/or with nohup) like

 nohup Xvfb :1 -screen 0 1152x900x8 &

然后,要使用它,请在本地主机上将显示设置为 :1,例如

 export DISPLAY="localhost:1"