To develop Java apps using Visual Studio Code (VS Code) with Java and Kotlin by IntelliJ IDEA extension inside the Windows Subsystem for Linux (WSL), you must run VS Code in a client-server architecture where the user interface stays on Windows while the Java runtime and project files reside purely on the Linux file system.
1. Install Necessary Windows Extensions
Launch VS Code natively on Windows and install these essential extensions from the Marketplace(Note: don't install VS Code in the WSL system):
- WSL Extension (by Microsoft): Enables the remote workspace pipeline.
2. Connect VS Code to WSL
-
In your WSL Linux terminal, navigate to your Gradle or Maven Java project folder:
mkdir -p ~/projects/my-gradle-app && cd ~/projects/my-gradle-app -
Launch VS Code from within Linux by running:
code . -
VS Code will automatically download and start the VS Code Server inside WSL.
-
This should take a short while and is only needed once.
Note: If this command does not work, you may need to restart your terminal or you may not have added VS Code to your path when it was installed.
-
-
Check the bottom-left corner of VS Code; a blue or green status box will display WSL: [YourDistroName] to confirm you are successfully remoted in.
4. Install Java and Kotlin by IntelliJ IDEA Extension Inside WSL
Once your workspace is connected to WSL, you must install your development tools into the remote instance.
- Press Ctrl + Shift + X to open the Extensions marketplace view.
- Search for the
IDEA Java, then choose itemJava and Kotlin by IntelliJ IDEA - Click Install in WSL: [YourDistroName]. This installs the language server backend, debugger, and Maven/Gradle dependencies directly inside Linux.
5. Running and Debugging Your Code
-
Create a simple test file named
Main.java.package com.example.demo; public class Main { public static void main(String[] args) { System.out.println("Hello World"); } } -
VS Code will boot the JetBrains Java Language Server.
-
Hit
F5or click Run | Debug floating text directly above yourmainmethod to compile and execute your logic smoothly inside the Linux shell environment.
Comments
0 comments
Please sign in to leave a comment.