简体   繁体   中英

Run and Debug Java in WSL 2 with Intellij IDEA on Windows 10

Intellij IDEA is installed on Windows. The java application built with maven requires native libraries (with JNI) and runs on Ubuntu.

Using maven and git on Windows is fine. How can I point Intellij IDEA to use the JDK from WSL so I can create a run/debug configuration that uses the WSL?

Deploy your app on WSL with Power Shell, and remote debug

  1. Install Intellij IDEA with version >= 2021.1.
  2. Configure WSL. To work with WSL 2, your Windows version should be 10 build 18917 or later. Make sure you add the needed JDK version in WSL. In order to use Maven, You also need to add a path variable export M2_HOME=/path/to/maven to the.profile file.
  3. Create, open and develop the project in corresponding WSL environment.
  4. Select the project SDK as the JDK configured in WSL.
  5. Ensure that firewalls allow connections using WSL.

More details: https://www.jetbrains.com/help/idea/2021.1/how-to-use-wsl-development-environment-in-product.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM