5

I have a Java application that uses WebRenderer for a java headless browser. WebRenderer does not require xserver to run and I have confirmed this by uninstalling all x11 libs and xserver components.

However the problem is it throws an error: Gtk-WARNING **: cannot open display: in certain conditions. Upon research I found that it usually throws that error with systems that have openJDK installed. Also when the current java version is from Sun but openJDK is still installed. To fix it I would need to uninstall libatk-wrapper-java and libgtk2.0-0 (which also removes default-jre, cedtea-netx, libatk-wrapper-java-jni, libgtk2.0-bin, and openjdk-6-jre).

It also throws the same error in openSUSE (with Java from Sun). Would there be any way to fix this error without having to start up xserver or uninstalling a bunch of components that could be required for something else? Any help is appreciated.

2
  • 2
    Do you start the JVM with java -Djava.awt.headless=true? Commented Aug 3, 2012 at 13:46
  • I have tried that but I get this: No protocol specified Gtk-WARNING **: cannot open display: Commented Aug 3, 2012 at 13:50

1 Answer 1

1

Yes, use Xvfb.

In one terminal, you run Xvfb :1. In the other terminal, you run DISPLAY=:1 ./yourapp.

Some distros have a xvfb-run script that does the magic of launching Xvfb and your app on the same command.

http://en.wikipedia.org/wiki/Xvfb

Google for Xvfb for more information

Sign up to request clarification or add additional context in comments.

3 Comments

However, running Xvfb :1 starts the xserver, atleast thats what it seems like. This could be a backup solution, but for now I am seeing if there is a way without running xserver.
Yes, but the goal of Xvfb is exactly to be used in this kind of situation. It won't require any graphics cards or do fancy stuff with your memory. It's way lighter than your normal "xserver". Either you fix the app or you give it a fake xserver with no screen.
Hmm I see. The only concern is when i do uninstall all the xserver libraries and libgtk it works fine. So in that case I dont really understand why it depends on xserver when libgtk is installed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.