java.lang.InternalError: unable to connect to the X11 window server for the JVisualVM profiling session


I have an Ubuntu server VM (myapp01) and have a Java application deployed there. The app has been acting wonky and I would like to profile it with JVisualVM. To do this I need to install X-Windows on my Windows 7 host, and then get the Ubuntu VM to export its X11 connection to my host when I tell it to run JVisualVM on the VM.

So I started by downloading XMing here:

I used all default/recommended installation options, including using a normal PuTTy session and allowing public & private network access. After installing XMing, I launched it and verified it was running on my Windows host. I then opened up Cygwin and SSHed into the Ubuntu server:

$ ssh [email protected]
[email protected]'s password:
Welcome to Ubuntu 12.04.4 LTS (GNU/Linux 3.5.0-23-generic x86_64)

* Documentation:

System information as of Tue Jun 10 21:26:15 EDT 2014

System load:  0.0                Processes:           82
Usage of /:   22.5% of 11.81GB   Users logged in:     0
Memory usage: 30%                IP address for eth0:
Swap usage:   0%

    Graph this data and manage this system at:

38 packages can be updated.
30 updates are security updates.

Last login: Tue Jun 10 15:03:35 2014 from

I then export the display to what appears to be my host's IP:

[email protected]:~$ export DISPLAY=

I then attempt to run JVisualVM:

[email protected]:~$ cd $JAVA_HOME
[email protected]:/usr/lib/jvm/java-7-oracle-amd64$ ls
[email protected]:/usr/lib/jvm/java-7-oracle-amd64$ cd bin/
[email protected]:/usr/lib/jvm/java-7-oracle-amd64/bin$ ./jvisualvm
Error: Can't connect to X11 window server using '' as the value of the DISPLAY variable.
See the /home/myuser/.visualvm/7u14/var/log/messages.log for details.
[email protected]:/usr/lib/jvm/java-7-oracle-amd64/bin$ vim /home/myuser/.visualvm/7u14/var/log/messages.log

Inside /home/myuser/.visualvm/7u14/var/log/messages.log:

java.lang.InternalError: Can't connect to X11 window server using '' as the value of the DISPLAY variable.
    at sun.awt.X11GraphicsEnvironment.initDisplay(Native Method)
    at sun.awt.X11GraphicsEnvironment.access$200(
    at sun.awt.X11GraphicsEnvironment$
    at Method)
    at sun.awt.X11GraphicsEnvironment.<clinit>(
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(
    at java.awt.GraphicsEnvironment.createGE(
    at java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(
    at org.netbeans.core.startup.Main.start(

Ideas? I am VPNed in, could that be affecting anything? Do I have XMing misconfigured somehow? Is my export DISPLAY command wrong? Anything else jumping out at anyone? Thanks in advance!

For security purposes, X servers won’t generally accept direct TCP connections from other hosts. Otherwise people could connect keyloggers to your X server, and your keystrokes would pass over the network unencrypted, allowing people to record passwords just by being on the same LAN.

But SSH provides a secure way to forward X11 traffic over your SSH session, using the -X or -Y options.

On your windows computer, make sure $DISPLAY is set correctly by trying to open an xterm from the command line. $DISPLAY will probably be set to :0 which stands for localhost:0. There are also additional tokens used to authenticate connections to the X server that are stored in ~/.Xauthority that you can view with xauth list.

Now, run ssh -Y If you get a message like X11 forwarding request failed on channel 0, then run ssh -v -Y instead to get debugging messages. If the remote machine is a server, the reason will probably be that xauth isn’t installed. On CentOS, it’s in the xorg-x11-xauth RPM.

On the remote machine, if everything went well, then $DISPLAY on the remote machine will now be set to a proxy display set up by SSH:

$ echo $DISPLAY

At which point you can run a command like xterm on the remote machine, and have the window pop up on your local display.

Although there’s no X server running on the remote machine, you may still need to install a bunch of X11 libraries for Java to be able to talk to your local X server…