S. Forman
S. Forman

Reputation: 119

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"
    }
}

Upvotes: 5

Views: 15460

Answers (2)

tlogbon
tlogbon

Reputation: 1312

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.

Upvotes: 4

S. Forman
S. Forman

Reputation: 119

I was able to solve this problem by using the File > Add Folder To Workspace option to create a new workspace that I can now run the debugger in.

Upvotes: 2

Related Questions