Skip to content

how to set JDK in UBUNTU-20.04 using VSCODE?

I am having problem with vscode and jdk, I use it in windows with many configs, but with ubuntu, It brings me this error: enter image description here

Everything is ok with jdk-default on vscode bash terminal.

jdk bin:

readlink -f $(which java) --> /usr/lib/jvm/java-11-openjdk-amd64/bin/java 

jdk version:

java --version
openjdk 11.0.11 2021-04-20
OpenJDK Runtime Environment (build 11.0.11+9-Ubuntu-0ubuntu2.20.04)
OpenJDK 64-Bit Server VM (build 11.0.11+9-Ubuntu-0ubuntu2.20.04, mixed mode, sharing)

but, if I try to found a $JAVA_HOME on terminal, it returns empty.. I do not know more what can I do… already changed other thigns like: configure.runtime: enter image description here

enter image description here


enter image description here

If someone could help me with some link, documentations, or anything, thanks!


You should set JAVA_HOME and Add JAVA bin directory to the PATH variable on local machine.

export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64

export PATH=$PATH:$JAVA_HOME/bin
echo $PATH

Once the above is finished, restart VS Code, below the Java Tooling Runtime tab, java extension should be able to detect the path automatically, then you can set java.home in VS Code successfully.

Don’t forget to reload window to make the setting effective.