I'm using Visual Studio Code to develop some code in Java. I tried a simple code as shown below :
int no_friends;
Scanner sc = new Scanner(System.in);
System.out.println("Enter values");
no_friends = sc.nextInt();
System.out.println("Value entered is : " + no_friends);
I placed a breakpoint on the sc.nextInt() line and the debugger successfully stopped this line. However, I did not find a way to give an input to the program while it is in debug mode. Is there a way to pass user input values to the code during debug mode ?
Replace the part in the launch.json
with
{
"type": "java",
"name": "Debug (Launch)",
"request": "launch",
"cwd": "${workspaceFolder}",
"console": "externalTerminal",
"stopOnEntry": false,
"mainClass": "",
"args": ""
}
Changing the console property to "integratedTerminal" in launch.json fixed the issue for for me.
"console": "integratedTerminal"
Hope that helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With