简体   繁体   中英

Setting JAVA_HOME for JDK 11 in Ubuntu for VSCODE

如何在 Ubuntu for Visual Studio Code 中为 JDK 11 设置 JAVA_HOME?

1 - Install jdk-11 or higher lts version via bash terminal:

sudo apt-get install openjdk-11-jdk

2- Find java path via bash terminal:

sudo update-alternatives --config java

Obs.: It will returns you a path like this:

/usr/lib/jvm/java-11-openjdk-amd64/bin/java (copy this path)

3- Edit /.bashrc adding JAVA_HOME to it via bash terminal:

sudo gedit ~/.bashrc

The code above will open the file, insert JAVA_HOME in the end of this, be careful, do not change anything here, just adding this code and SAVE:

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

Obs.: JAVA_HOME= **put your java path without "/bin/java" here **

4- Set Vscode jdk path variable:

-press F1 and type Sttings Sync: Show Settings

-inside serarch settings put @tag:sync

-find and open settings.json like this:

在此处输入图片说明

-now you just need to put your JAVA_HOME like this:

    "java.home": "/usr/lib/jvm/java-11-openjdk-amd64",
    
    "java.configuration.runtimes": [
        {
            "name":"JavaSE-11",
            "path": "/usr/lib/jvm/java-11-openjdk-amd64"
        }
    ],

在此处输入图片说明

reload vscode window, or just close it and open agin

...and VOALA ! now the JDK is visible * -- *

在此处输入图片说明

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