简体   繁体   中英

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: 在此处输入图片说明

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: 在此处输入图片说明

在此处输入图片说明

json.conf:

在此处输入图片说明

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
echo $JAVA_HOME

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.

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