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

久未见 提交于 2021-01-27 21:45:47

问题


I Have a java application that requires X11 DISPLAY variable, the exception I am getting is:

    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)

I've installed Xvfb on the ubuntu machine:

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

But I am still getting this error.

When I start Xvfb I am getting the following response:

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!

and It doesn't return back to me, so I press 'CTRL + C' to take back control, but after looking at 'ps aux | grep Xvfb' I can see the process is running, so I am not sure if it worked or not.

Any help would be greatly appreciated.

Thanks


回答1:


You aren't getting an error, those are warning messages about old fonts. Start the virtual X server in the background (and/or with nohup) like

 nohup Xvfb :1 -screen 0 1152x900x8 &

And then, to use it, set your display to :1 on localhost like

 export DISPLAY="localhost:1"


来源:https://stackoverflow.com/questions/39388037/java-awt-requires-x11-how-to-use-xvfb-ubuntu-14-04

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!