Vscode-java-debug: "Failed to evaluate. Reason: Cannot evaluate because the thread is resumed."

Created on 23 Feb 2018  路  4Comments  路  Source: microsoft/vscode-java-debug

When using the Scanner class, the debugger does nothing when typing in a value. It stops with the message below.

Environment
  • Operating System: Windows 10 Professional x64
  • JDK version: 8u161
  • Visual Studio Code version: 1.20.1
  • Java extension version: 0.19.0
  • Java Debugger extension version: 0.6.0
Steps To Reproduce
  1. Create a class with public static void main method
  2. Create a new Scanner(System.in)
  3. Create a variable and let the scanner read in an integer
  4. Run the debugger
public static void main( String[] args )
 {
     Scanner scanner = new Scanner(System.in);
     int x = scanner.nextInt();
     scanner.close();
 }
Current Result

Failed to evaluate. Reason: Cannot evaluate because the thread is resumed.
error1

Expected Result
Additional Informations

There is nothing more. No breakpoint set, just created a default java launch and it stopped there

Most helpful comment

@Victorious3 For this issue:

  1. "Cannot evaluate because the thread is resumed" is by design of java debug by Sun, you need to stop at a breakpoint/step before you could start evaluation.
  2. The cause for this issue is user want to input by misunderstanding of vscode design for debug console(which is used to input text for evaluation)
  3. If you do want to input in vscode, vscode has a solution which is to use "externalTerminal" or "integratedTerminal" in launch.json, see docuement about input in terminal at https://code.visualstudio.com/docs/editor/integrated-terminal

All 4 comments

Based on "The default Debug Console in VS Code doesn't support inputs. In case your program need inputs from terminal, you can use Integrated Terminal within VS Code or external terminal to launch it.."
https://code.visualstudio.com/docs/java/java-debugging

My workaround is to edit the launch.json and change console to use integratedTerminal

Oh, I must have completely skipped over that part.

The workaround is acceptable, but it would be nicer, if VS Code would support inputs from terminal.

Thanks a lot.

I'm not sure why this is closed? There's a workaround, yes, but does that mean it's not an issue?
Is there any reason why the debug console shouldn't accept inputs?

@Victorious3 For this issue:

  1. "Cannot evaluate because the thread is resumed" is by design of java debug by Sun, you need to stop at a breakpoint/step before you could start evaluation.
  2. The cause for this issue is user want to input by misunderstanding of vscode design for debug console(which is used to input text for evaluation)
  3. If you do want to input in vscode, vscode has a solution which is to use "externalTerminal" or "integratedTerminal" in launch.json, see docuement about input in terminal at https://code.visualstudio.com/docs/editor/integrated-terminal
Was this page helpful?
0 / 5 - 0 ratings

Related issues

mojo2012 picture mojo2012  路  3Comments

erihanse picture erihanse  路  3Comments

testforstephen picture testforstephen  路  4Comments

AlexMAS picture AlexMAS  路  5Comments

dgileadi picture dgileadi  路  3Comments