GUI forwarding
Last modified: 29 November 2022If you develop a web application or some other project that contains Graphical User Interface (GUI) remotely, you can forward GUI from a remote server to JetBrains Client using Xpra or VNC viewer.
note
For VNC, a window manager such as fluxbox or any other is required on the remote server.
Xpra configuration
When you work with Xpra, keep its pros and cons in mind:
It handles each window by itself and displays it as a native window on your local machine.
It handles HiDPI better than VNC.
It sets up the whole environment by itself, only a single command needs to be started.
It allows you to forward different items and devices such as clipboard, sound, cameras, and so on.
It allows you to forward a real desktop.
It can work as a server also on Windows and macOS.
It is quite heavy because ships a lot of additional items.
In some distributions such as Ubuntu, Xpra has quite an old version (3.1.3) while the version 4.3.4 is the latest
Configure Xpra for a remote project
Connect to your remote server and enter the following command:
sudo apt-get install xpra x11vnc xvfb
Note that the package name might be different in the distributions other than Ubuntu or Debian.
On you local machine, install the Xpra application.
note
If you have macOS as your local machine, use Homebrew for installation or make sure to read Xpra documentation to bypass system security restrictions on macOS.
Open the remote project using JetBrains Gateway.
Open the embedded terminal and execute the following command:
xpra start --bind-tcp=0.0.0.0:10000 --use-display=no --daemon=no :10
Click
forward
at the terminal suggestion to forward an opened port10000
.On your local machine, in the local terminal, execute the following command:
xpra attach tcp://localhost:10000
The port number is taken from the
forwarded to
label in the terminal tool window.note
On Windows, Xpra is not in
PATH
by default. Use the full path to the Xpra installation such as"C:\Program Files\xpra\xpra_cmd.exe" attach tcp://localhost:10000
In JetBrains Client, from the main menu, select Edit Configurations to open the desired run configuration with your GUI application.
In the Run/Debug Configurations dialog, in the Environment Variables field, add
DISPLAY=:10
and click OK to save the changes.On the main menu, click Run next to your configuration.
The application window forwarder by Xpra gets displayed.
VNC configuration
When you work with VNC, keep the following pros and cons in mind:
Xvfb and x11vnc are standard Linux tools.
VNC is lighter comparing to Xpra.
As a prerequisite, a window manager such as
fluxbox
has to be installed on a remote server.The windows aren't rendered natively on your machine.
It is not displayed properly on the HiDPI screens.
Configure VNC for a remote project
Connect to your remote server and enter the following command:
sudo apt-get install x11vnc xvfb fluxbox
Note that the package name might be different in the distributions other than Ubuntu or Debian.
On your local machine, install a VNC client, such as tigervnc or any alternative VNC client.
note
For Linux, use the
apt-get
command. For Windows or macOS, you need to install the VNC client manually.Open the remote project using JetBrains Gateway.
Open the embedded terminal and execute the following command:
Xvfb :10 -screen 0 1920x1080x24 & DISPLAY=:10 fluxbox & x11vnc -display :10 -autoport 10000 -localhost -scale 1.75
note
-scale 1.75
should be changed to the scale factor of your local HiDPI display.Click
forward
at the terminal suggestion to forward an opened port10000
.On your local machine, in the local terminal, execute the following command:
vncviewer localhost:10000
The port number is taken from the
forwarded to
label in the terminal tool window.note
If you use an alternative VNC client, specify its address manually through GUI or command line.
An empty VNC session gets started.
In JetBrains Client, from the main menu, select Edit Configurations to open the desired run configuration with your GUI application.
In the Run/Debug Configurations dialog, in the Environment Variables field, add
DISPLAY=:10
and click OK to save the changes.On the main menu, click Run next to your configuration.
You should see your application inside the VNC viewer. In the case of HiDPI, your application may look blurry.
Thanks for your feedback!