Run Eclipse/STS on Windows WSL

Problem

In some companies, App Defender/AppLocker makes the entire Windows OS practically unusable. EXEs are blocked, and the virus scan slows any build to a crawl. Nevertheless, we still need to work, and WSL is often the only feasible solution. But how can we start, for example, Eclipse or any other application in WSL that requires a screen?

Solution

We might wither build on x11 (steps 4 and 5) or use the build in WSLg which should run out of the box:

  1. Install eclipse or STS in Linux
  2. Export the DISPLAY env variable export DISPLAY=:0
  3. Run eclipse or any other application in Linux
  4. (optional) Install x11 in Linux sudo apt install x11-xserver-utils
  5. (optional) Install VcXsrv on windows

Install eclipse or Spring STS in Linux

We might either install eclipse with sudo apt install eclipse or as many other of us choose to install a different IDE here an example for spring sts (update the URL as needed to the current version):

wget https://cdn.spring.io/spring-tools/release/STS4/4.25.0.RELEASE/dist/e4.33/spring-tool-suite-4-4.25.0.RELEASE-e4.33.0-linux.gtk.x86_64.tar.gz
tar -xvf spring-tool-suite-4-4.25.0.RELEASE-e4.33.0-linux.gtk.x86_64.tar.gz
rm -rf spring-tool*
ln -s sts-4.25.0.RELEASE/SpringToolSuite4 sts

Export the DISPLAY env variable

In order to find our windows screen we have to define the DISPLAY destination with the same named environment variable. The simplest way is to extend the .profile that it is automatically exported on each shell start (or .zprofile if zsh is used).

export DISPLAY=:0

Run eclipse or any other application

Now we can either start eclipse using ./eclipse or the spring STS using ./sts.

In case of any issues the x11 app might help you e.g. using xeyes:

sudo apt install x11-apps
xeyes

Install x11 in Linux

x11 tools on Linux are responsible to send the screen information from our Linux system to windows and on the other hand receive mouse and keyboard commands. In ubuntu the tools can be installed by using:

sudo apt install x11-xserver-utils

This step is not need anymore on a newer WSL as by default windows support UI apps in the WSL using WSLg.

If x11 is used the DISPLAY variable has to be adjusted to point to the Windows Host machine.

Install VcXsrv on windows

In order to receive the screen information from Linux in Windows and to display the application started in Linux we need an x11 client here too. First we have to install VcXsrv and start it using XLaunch which will prompt us of the settings:

  1. Multiple windows in the display settings, which allows us to start more than one app
  2. Start no client which of course requires us to start the app in Linux manually later on

Everything else may stay in the default settings.

This step is not need anymore on a newer WSL as by default windows support UI apps in the WSL using WSLg.

Alternatives

Paul Sterl has written 54 articles

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>