# IntelliJ under WSL
* Install WSL according to <https://docs.microsoft.com/en-us/windows/wsl/install>
* Install various software:
* `wget https://corretto.aws/downloads/latest/amazon-corretto-8-x64-linux-jdk.deb -O amazon-corretto-8-x64-linux-jdk.deb`
* `sudo apt install ./amazon-corretto-8-x64-linux-jdk.deb`
* `sudo apt install maven openssh-server zip curl`
* `curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash`
* `nvm install --lts`
* `source ~/.bashrc`
* Edit `/etc/ssh/sshd_config` and change port number to 2222
* `sudo nano /etc/ssh/sshd_config`
* Change `# Port 22` to `Port 2222`
* Restart openssh server:
* `sudo /etc/init.d/ssh restart`
* Add ssh public key to authorized_keys
* `nano ~/.ssh/authorized_keys`
* Paste public key into the file. It can be found by loading your private key i PuTTYgen.
* Make sure your private key is loaded in Pageant and open a Putty session to `<yourusername>@localhost` on port `2222`
* You should now be able to access the WSL linux instance with Putty
* From windows install VcXsrv: https://sourceforge.net/projects/vcxsrv/
* From windows run Xlaunch:
* Select "Multiple windows" on the first screen
* Select "Start no client" on the second screen
* Check the box next to "Disable access control" on the third screen
* On the fourth screen select "Save configuration" and save to a place you can remember, for example `c:\Users\<username>\default.xlaunch`
* Click finish
* In linux, setup `DISPLAY` variable
* Edit the global bashrc: `sudo nano /etc/bash.bashrc`
* Add the following line at the bottom of the file: `export DISPLAY=$(ip route | awk '/^default/{print $3}'):0.0`
* Log out and back in to linux and check that `DISPLAY` is set: `env | grep DISP`
* Test that X is working:
* `sudo apt install xclock`
* `xclock`
* This should start an xclock window as a native windows window
* Download IntelliJ:
* `wget 'https://download.jetbrains.com/idea/ideaIU-2022.1.tar.gz'`
* `tar xvzf ideaIU-2022.1.tar.gz`
* `sudo mv idea-IU-221.5080.210 /opt`
* Run IntelliJ:
* `/opt/idea-IU-213.7172.25/bin/idea.sh`
## Automatic start of everything
* Start Xlaunch on windows startup:
* Open `run.exe` and input `shell:common startup` to open the windows startup folder
* In the folder create a shortcut to `"C:\Program Files\VcXsrv\xlaunch.exe" -run "c:\Users\<username>\default.xlaunch"`
* Make sure ssh server is running on startup:
* Follow the guide under "Add a Windows Task Scheduler to automatically start ssh server" on the following page: <https://www.illuminiastudios.com/dev-diaries/ssh-on-windows-subsystem-for-linux/>