Setup and run IntelliJ in WSL2

Purpose of article

There are plenty of resources online, this is an article for my future reference and keep track of what worked for me.

Setup

  1. Install XMing
  2. Setup WSL2 (Ubuntu 20.04)

Key Configuration

  1. Instead of run Xming directly, go for XLaunch, and check no Access Control

2. In WSL, export the DISPLAY with command in your shell:

export DISPLAY=$(cat /etc/resolv.conf | grep nameserver | awk ‘{print $2; exit;}’):0

You might also be able to check the address directly from Xming log file:

and then run follow command in your shell:

export DISPLAY=172.26.0.1:0

With the first approach, one can just add that export command into ~/.bashrc so everytime you open the WSL2 shell, it would be executed.

Execute IntelliJ

run following command:

sh /path/to/intellij/idea/folder/bin/idea.sh
It opens !!!!! YEAH~

I normally use following command but it throw error:

. /path/to/intellij/idea/folder/bin/idea.sh

Also side effect of using . that throw error is the shell got terminated

Useful Reference

Install IntelliJ

Advanced guide for configure WSL2 and X11 forward

To access files between WSL2 and Windows

What might not be needed

Some reference say open firewall for the Xming (or other X Server like program), I did added the rule, but after disabling the rule and it still work fine, so I guess it’s not strictly necessary?

--

--

--

Love podcasts or audiobooks? Learn on the go with our new app.

Which packages are required to run a static binary in a Docker Image

GCP — SFMC Data Pipeline pt 1

How To Leverage Medium for Crypto-trading

The Building Blocks Thesis -Volume 1

How to add Token in MetaMask:

Cloud computing

Learning C++: for Loops

Web App Development In 2021- Process, Framework, Cost & More

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Stephen Cow Chau

Stephen Cow Chau

More from Medium

Goodbye Migration Hell in Java! Say Hello to Flyway

How To: Code Functional style with spring kafka streams (plus some avro goodness)

Generate a Bearer Token without extra libraries

Getting Java-11 docker images to run on mac m1 (arm64) with adoptium/temurin