简体   繁体   中英

How to set java classpath in Visual Studio Code (v 1.27.2)?

I am new to Visual Studio Code for Java development and I had a workspace open yesterday for testing. Now when restarting Visual Studio today, I get a "Classpath is incomplete" warning when I open any java file and I cannot get any tests to run. Looking at what must be the workspace file, it only contains the following. Is it missing something that sets the class path, or is there some other way to solve this problem?

{
    "folders": [
        {
            "path": "<path to project directory>"
        }
    ],
    "settings": {
        "java.configuration.updateBuildConfiguration": "automatic"
    }
}

我能够通过使用文件 > 添加文件夹到工作区选项来创建一个新的工作区来解决这个问题,我现在可以在其中运行调试器。

Currently, using version 1.60.x, solved this with the following steps on MacOS

  • Cmd + Shift + P
  • Type: "Java: Configure Classpath", press enter
  • On the option screen that opens, scroll to the bottom, you'll see the "Referenced Libraries", click on "Add" and browse to the path of the Jars to reference, you can select multiple jars in a folder.
  • After doing this, you can run the "Java: Update Project" command or just try to run the Java code.

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