A /dev/null equivilent for DISPLAY when the display is just noise

前端 未结 5 1624
春和景丽
春和景丽 2021-02-05 06:39

I\'m running a java app which creates a visual display of some of the things it is doing, while it is doing it. However, I\'m want to run this in a script that won\'t have a dis

相关标签:
5条回答
  • 2021-02-05 06:56

    There's a headless X server called Xvfb. It's basically what you need since it accepts X clients but basically does nothing with the data from them. From that linked page (slightly paraphrased):

    Xvfb, the X virtual framebuffer, is a display server implementing the X11 display server protocol.

    In contrast to other display servers, Xvfb performs all graphical operations in memory without showing any screen output.

    From the point of view of the client, it acts exactly like any other X display server, serving requests and sending events and errors as appropriate. However, no output is shown.

    This virtual server does not require the computer it is running on to have a screen or any input device. Only a network layer is necessary.

    If you can't find that, then another possibility would be to use a spare PC with a full CygWin install. CygWin comes with a full-blown X server which you could connect your application to (and just ignore it). You could even set it up as the corporate /dev/null DISPLAY.

    But I'd look into Xvfb first.

    0 讨论(0)
  • 2021-02-05 07:02

    You can use Xvfb, as noted above. That way, you will never see the output (you can use a tool to take screenshots, though).

    http://en.wikipedia.org/wiki/Xvfb http://packages.debian.org/sid/xvfb

    Or you could set up a VNC server. Under Linux, a VNC server is implemented as a special X server that can be accessed via VNC, insstead of displaying on a local monitor. That gives you a headless X server, with the added bonus that you can connect to it via VNC just in case you do need to see what's going on.

    http://www.tightvnc.com/vncserver.1.html

    vncserver is a nice wrapper script for (tight)VNC, which makes starting a VNC server a breeze. Most distros should install it by default.

    0 讨论(0)
  • 2021-02-05 07:06

    If it's a java program you can use the headless mode to run the application.

    Try to run it with -Djava.awt.headless=true parameter, like this if it's a jar file:

    java -Djava.awt.headless=true -jar jarfile.jar

    More about headless mode...

    0 讨论(0)
  • 2021-02-05 07:07

    Short answer, use:

    xvfb-run JAVA_COMMAND_LINE
    

    Depending on your version and flavor of Linux, there may be one line you have to change in xvfb-run to get everything to run.

    0 讨论(0)
  • 2021-02-05 07:12

    Can you run a VM on the target machine? Then you could set your DISPLAY to that. Or you could try vnc (currently on a machine which doesn't allow this or I'd try it...).

    0 讨论(0)
提交回复
热议问题