How to install IntelliJ IDEA in Ubuntu on WSL with X410

How to install IntelliJ IDEA in Ubuntu on WSL with X410

Overview

  • With the advent of WSL2, using native Linux environments has become possible on Windows operating systems. I highly recommend using X410 as it allows running all GUI applications from the WSL2 distro. IntelliJ IDEA installed on WSL2 distro demonstrates significantly faster and smoother performance, free from the interference of firewalls, and antivirus software. This article introduces how to install and configure X410 and IntelliJ IDEA.

Prerequisites

  • Windows 11 operating system with WSL2 enabled, and Ubuntu on WSL installed is required. [Related Link]

File Monitoring Performance Optimization

  • For larger projects, the number of files IntelliJ IDEA needs to monitor increases. The maximum number of files to be monitored can be increased as follows. [Related Link]
$ sudo apt-get install inotify-tools -y
$ sudo sh -c "echo \"fs.inotify.max_user_watches = 524288\" >> /etc/sysctl.conf"
$ sudo sysctl -p --system
fs.inotify.max_user_watches = 524288

Installing JetBrains Toolbox

  • Installing JetBrains Toolbox is more convenient than directly installing IntelliJ IDEA.
# Downloading and extracting JetBrains Toolbox
$ cd ~
$ sudo apt-get install libfuse2 libxt6 libxi6 libxtst6
$ wget https://download.jetbrains.com/toolbox/jetbrains-toolbox-2.1.3.18901.tar.gz
$ sudo rm -rf /opt/toolbox
$ sudo mkdir /opt/toolbox
$ sudo tar -xzvf jetbrains-toolbox-2.1.3.18901.tar.gz -C /opt/toolbox
$ sudo ln -sf /opt/toolbox/jetbrains-toolbox-2.1.3.18901 /opt/jetbrains-toolbox

# Registering aliases for toolbox and idea
$ nano ~/.bash_aliases
alias toolbox="/opt/jetbrains-toolbox/jetbrains-toolbox > /dev/null 2>&1 &"
alias idea="~/.local/share/JetBrains/Toolbox/apps/intellij-idea-ultimate/bin/idea.sh > /dev/null 2>&1 &"
alias idea.="~/.local/share/JetBrains/Toolbox/apps/intellij-idea-ultimate/bin/idea.sh . > /dev/null 2>&1 &"
  • Once the JetBrains Toolbox installation is complete, run the toolbox alias to install IntelliJ IDEA.

Direct Installation of IntelliJ IDEA

  • Below is a method to install IntelliJ IDEA directly without using JetBrains Toolbox.
# Downloading and extracting IntelliJ IDEA
$ cd ~
$ wget https://download.jetbrains.com/idea/ideaIU-2023.3.tar.gz
$ sudo rm -rf /opt/intellij /opt/idea
$ sudo mkdir /opt/intellij
$ sudo tar -xzvf ideaIU-2023.3.tar.gz -C /opt/intellij

# Creating a symbolic link to /opt/idea
$ sudo ln -sf /opt/intellij/idea-IU-233.11799.241/ /opt/idea

# Registering aliases for idea
$ nano ~/.bash_aliases
alias idea="/opt/idea/bin/idea.sh > /dev/null 2>&1 &"
alias idea.="/opt/idea/bin/idea.sh . > /dev/null 2>&1 &"

Running IntelliJ IDEA

# Running IntelliJ IDEA
$ idea

# Running IntelliJ IDEA in the current project directory
$ idea.

Setting Default Browser in IntelliJ IDEA

Settings → Tools → Web Browsers and Preview
- Default Browser: [Custom path]
- Custom Path: /mnt/c/Program Files/Google/Chrome/Application/chrome.exe (Enter this path)

Resetting IntelliJ IDEA Settings

$ rm -rf ~/.config/JetBrains ~/.cache/JetBrains ~/.local/share/JetBrains

(Optional) Installing X410

  • When running IntelliJ IDEA in a WSL 2 environment, software that performs the role of an X Server is necessary for the screen to display properly. If Windows 11 and WSL 2 are updated to the latest version, WSLg, which performs this role, is already installed, so IntelliJ IDEA can be run normally without any additional work.

  • One issue is that WSLg is optimized for Wayland rather than X Server, and since IntelliJ IDEA does not yet support Wayland, the UI experience might be unsatisfactory. [Related Link] If you are not satisfied with WSLg, purchasing the paid X Server software, X410, is recommended.

  • X410 can be purchased from the Windows Store. [Installation Link]

  • Once purchased, complete the setup as guided on the official website. [Guide Link]

# Add X410 configuration to ~/.bashrc file
$ nano ~/.bashrc
export DISPLAY=$(cat /etc/resolv.conf | grep nameserver | awk '{print $2; exit;}'):0.0
export DISPLAY=$(ip route | grep default | awk '{print $3; exit;}'):0.0

(Optional) Installing Recursive Font

  • I personally prefer Rec Mono Duotone as a coding font. You can install it as follows.
$ mkdir ~/.fonts
$ cd ~/.fonts
$ wget https://github.com/arrowtype/recursive/releases/download/v1.085/ArrowType-Recursive-1.085.zip
$ unzip ArrowType-Recursive-1.085.zip
$ rm ArrowType-Recursive-1.085.zip

(Optional) Installing fcitx Korean Input Method

  • Ubuntu on WSL does not support Korean input in the GUI by default. The fcitx Korean input method can be installed as follows.
# Installing fcitx Korean input method
$ sudo apt-get install fcitx fcitx-hangul fonts-noto-cjk fonts-noto-color-emoji fonts-nanum* dbus-x11 -y

# Setting fcitx as the default Korean input method
$ im-config

$ sudo sh -c "dbus-uuidgen >> /var/lib/dbus/machine-id"

# Adding Hangul to Input Method
$ fcitx-config-gtk3

References