Intellij IDEA from WSL2
Running GUI application from WSL2 terminal
Intellij IDEA does not have plugin such as Visual Studio Code Remote Development, nevertheless it is possible to run linux GUI applications directly from WSL2 terminal by installing an X Server for Windows.
Install Windows X Server
Install VcXsrv that is an open-source and frequently updated Windows X Server (it will be the provider of graphics resources and keyboard/mouse events), then start it as follow:
- Use multiple windows
- Do not start client
- Check
disable access control
or add-ac
into the additional parameters, it will avoid permission denied error when trying to run a GUI application.
- Then you can save the configuration in order to reuse it later to launch VcXsvr directly with the right configuration.
Windows firewall settings
Check that the Windows firewall settings are correctly configured, it must have both public and private checked for VcXsvr windows xserver
.
Settings are accesibles from Windows settings > Update and security > Windows Securities > Firewall and network protection > Allow an application through firewall
WSL2 terminal configuration
The WSL2 terminal must be configured to set and export the DISPLAY
environnment variable to use the Windows host’s IP of WSL2. The IP can be retrieve from the file /etc/resolv.conf
that is generated by WSL2. Add the following lines into the .bashrc
file to export needed variables
|
|
Launch VcXsvr, then verify it works correctly by launching xeyes
, install it if it is not already done.
Install IntelliJ on WSL2
Install the following dependencies, such as you should have all needed libraries to run Jetbrains Toolbox and IntelliJ.
|
|
I suggest to use Jetbrains Toolbox to install and update IntelliJ version.
Install Jetbrains Toolbox
Download JetBrains Toolbox
with the following command:
|
|
Then extract the file jetbrains-toolbox.tar.gz
into a folder and launch the application, then install Intellij IDEA community edition.
I advice to enable the “Shell Scripts” feature from Jetbrains Toolbox settings such as scripts will be generated into a folder of your choose (for instance ~/dev/tools/jb
). Thanks to this script, it will be easy to launch IntelliJ IDEA.