0

I installed java jdk using sdkman on my windows machine. I am using wsl for this purpose.

enter image description here

However, I need to add this to my VScode and when I look at the installed jdk's available to me I only see these:

enter image description here

This does not display the JDK I installed using sdkman which is located in the folder \\wsl$\Ubuntu\home\devt\.sdkman\candidates\java. I do not know how to direct my JAVA_HOME variable to this location.

James Z
  • 12,209
  • 10
  • 24
  • 44
TanDev
  • 359
  • 3
  • 5
  • 13
  • Why would you want to use a Linux JDK on windows? – Axel Feb 09 '21 at 05:04
  • our professor said we should use sdkman to download java 11 and I did it using wsl. – TanDev Feb 09 '21 at 05:05
  • i am very confused about that part and if i messed up – TanDev Feb 09 '21 at 05:06
  • Could it be he meant you should use sdkman only if you are using Linux? – Axel Feb 09 '21 at 05:07
  • is it possible to run sdkman on the windows command prompt? – TanDev Feb 09 '21 at 05:09
  • You will probably not be able to create a user interface and also run into other difficulties when using a Linux JDK under windows. Just install the windows version of whatever JDK he told you to install and use that one in VSCode. – Axel Feb 09 '21 at 05:10
  • i mean I googled it and it said we need WSL..however when I downloaded sdkman and the JDK using sdkman, it gets placed in this \\wsl$\Ubuntu\home\devt\.sdkman\candidates\java which is not accessible when i try to set the path or something – TanDev Feb 09 '21 at 05:11
  • Just install a windows version of the JDK. Using sdkman on windows will probably give you nothing but trouble. – Axel Feb 09 '21 at 05:14
  • thats exactly what I am experiencing... TROUBLEE!! – TanDev Feb 09 '21 at 05:15
  • Add the sdkman path to java.home in vscode settings.json – kenchew Jun 26 '21 at 08:15
  • https://code.visualstudio.com/docs/remote/wsl – Abhinav Kulshreshtha May 05 '22 at 05:23

2 Answers2

0

They now provide a complete extension for connection to wsl. WSL is a separate user-space inside NT kernel. Your VS-Code is running in windows userspace. Hard way to do it would be to remote into your wsl, and configure there. Easy way would be to install vscode inside wsl, because windows now let you install and use linux GUI apps via wsl. Or use the extension they provide, which works on the microsoft build of vscode,( It doesn't work with non-microsoft binaries of vscode, like code-oss, vscodium etc.)

Complete instructions on working with WSL is documented here. https://code.visualstudio.com/docs/remote/wsl

Abhinav Kulshreshtha
  • 2,147
  • 1
  • 23
  • 38
0

first step

(- Install java jdk first

  • open settings in vs code
  • search for "jdk" in settings
  • In java Home
  • paste the jdk path:- C:\Program Files\Java\jdk-20\bin )

2nd Step (

  • open settings in vs code
  • search for "jdk" in settings
  • In java Home - settings json -(Open it) and add

"java.home":"C:\Program Files\Java\jdk1.8.0_161"

)

  • 1
    Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jul 01 '23 at 06:09