# 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\]](https://jsonobject.tistory.com/9)
    

### 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\]](https://doc.networknt.com/tool/idea/settings/)
    

```bash
$ 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**.
    

```bash
# 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**.
    

```bash
# 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

```bash
# Running IntelliJ IDEA
$ idea

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

### Setting Default Browser in IntelliJ IDEA

```bash
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

```bash
$ 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\]](https://youtrack.jetbrains.com/issue/JBR-3206/Native-Wayland-support) 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\]](https://www.microsoft.com/en-us/p/x410/9nlp712zmn9q)
    
* Once purchased, complete the setup as guided on the official website. [\[Guide Link\]](https://x410.dev/cookbook/wsl/using-x410-with-wsl2/)
    

```bash
# 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.
    

```bash
$ 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.
    

```bash
# 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

* [Lightning speed development on Windows 10 with WSL 2, Docker, Terminal and Jetbrains IntelliJ/PyCharm/PHPStorm](https://www.pimwiddershoven.nl/entry/lightning-speed-development-on-windows-10-with-wsl-2-docker-terminal-and-jetbrains-intellij-pycharm-phpstorm)
    
* [Setup Input Method for WSL](https://patrickwu.space/2019/10/28/wsl-fcitx-setup/)
