0

I'm using Visual Studio Code for Java and I want to debug my code while using a Library. But whenever I start debugging I'm getting the following error:

Exception in thread "main" java.lang.Error: Unresolved compilation problems: 
    IO cannot be resolved
    IO cannot be resolved
    IO cannot be resolved

    at TestClass.main(TestClass.java:6)

for example with the following code:

import AlgoTools.IO;

public class TestClass {
    public static void main(String[] args) {
        int a, b;
        a = IO.readInt("Please enter a number ");
        b = IO.readInt("Please enter another number ");

        IO.println("Your number is: " + (a + b));
    }
}

But when I compile my code in cmd or PowerShell using javac <Filename> and running it with java <Classname> it works fine. I'm only getting errors when I try to debug in Visual Studio Code.

I should also mention, that I added the path to my .jar Libary in my CLASSPATH.

I'm using the default "Launch" debugging configuration:

{
    "type": "java",
    "name": "Debug (Launch)",
    "request": "launch",
    "cwd": "${workspaceFolder}",
    "console": "internalConsole",
    "stopOnEntry": false,
    "mainClass": "",
    "args": ""
},
  • Possible duplicate of [Setting the classpath in a Visual Studio Code Maven-based Java project](https://stackoverflow.com/questions/50749388/setting-the-classpath-in-a-visual-studio-code-maven-based-java-project) – Robin Green Nov 25 '18 at 11:52
  • I don't use maven, I don't even know how I should use it. I just want to debug some code for school in VSC. Or do you recommend using maven and when you do, why? –  Nov 25 '18 at 12:30
  • Ok, I read a little bit about Maven and I should add, that you can't find the Libary in the maven archives (as far as I know), because it's a library from our university. –  Nov 25 '18 at 14:40
  • I think the answer to that question is applicable even if you don't use Maven. – Robin Green Nov 25 '18 at 15:17

1 Answers1

0

you should install a extension called "java extension pack" and java maven. or install that offline extension.click here and get extension name

Extension URL : https://marketplace.visualstudio.com/_apis/public/gallery/publishers/vscjava/vsextensions/vscode-java-pack/0.4.0/vspackage

Atul Kumar
  • 324
  • 4
  • 8
  • I already installed the java extension pack. and Java Maven is in the expansion pack, so I already installed it but I don't really know how to use Maven. –  Nov 25 '18 at 12:32
  • go to menu bar and select debug menu and click start without debugging. – Atul Kumar Nov 25 '18 at 16:25
  • I'm getting the same error. Besides that, I want to use the debug features of VSC. –  Nov 25 '18 at 20:51