[Java] Build VS Code+WSL+Java+Gradle environment from scratch

less than 1 minute read

Install JDK on Windows

  • Check if JDK is installed from command line
C:\Users\ username> javac -version
javac 11.0.7
  • If the JDK is not installed, install it with the installer

https://adoptopenjdk.net/ “Open JDK 11 (LTS)” “HotSpot” *Check to set the environment variable “JAVA_HOME” during installation

  • Check if the environment variable “JAVA_HOME” is set
C:\Users\username> echo %JAVA_HOME%
C:\Program Files\AdoptOpenJDK\jdk-

If blank is output, set the environment variable “JAVA_HOME”

Install VSCode on Windows

  • Installer https://azure.microsoft.com/ja-jp/products/visual-studio-code/

Install extension so that VS Code can handle Java

Extension name Code
Java Extension Pack vscjava.vscode-java-pack
Lombok Annotations Support for VS Code gabrielbb.vscode-lombok
Checkstyle for Java shengchen.vscode-checkstyle
SonarLint sonarsource.sonarlint-vscode
Gradle Language Support naco-siren.gradle-language
Markdown All in One yzhang.markdown-all-in-one
Remote-WSL ms-vscode-remote.remote-wsl

Install WSL on Windows

  • Reference article https://qiita.com/oyngtmhr/items/a098e2da50bc7b58d75a

Enable Java on WSL

  • Reference article https://qiita.com/sakamoto66/items/bf49584fa9f56a9fb808

Enable Gradle on WSL

  • Reference article https://qiita.com/fedorax/items/40052e150865267d1fa0

Install VSCode extension in WSL to develop on WSL via #VSCode

  1. Open WSL from “><” at the bottom left of VS Code run-wsl.png
  2. Select the extension icon from the toolbar on the edge of the VS Code screen.
  3. Install all extensions you have in WSL vscode-java.png