DonJayamanne / javaVSCode

Extension for java development on VSCode (deprecated)
https://marketplace.visualstudio.com/items?itemName=donjayamanne.javaDebugger
MIT License
43 stars 30 forks source link

Not able to capture user input on internal terminal when debugging JAVA file #72

Closed GorvGoyl closed 6 years ago

GorvGoyl commented 6 years ago

From @JerryGoyal on September 10, 2017 6:45

Steps to Reproduce:

  1. Install java debugger extension https://marketplace.visualstudio.com/items?itemName=donjayamanne.javaDebugger

  2. configure launch.json:

    {
    "version": "0.2.0",
    "configurations": [
    
        {
            "name": "Debug Java",
            "type": "java",
            "request": "launch",
            "externalConsole": false,                //user input dosen't work if set it to false :(
            "stopOnEntry": true,
            "preLaunchTask": "build",                 // Runs the task created above before running this configuration
            "jdkPath": "${env:JAVA_HOME}/bin",        // You need to set JAVA_HOME enviroment variable
            "cwd": "${workspaceRoot}",
            "startupClass": "${workspaceRoot}${file}",
            "sourcePath": ["${workspaceRoot}"],   // Indicates where your source (.java) files are
            "classpath": ["${workspaceRoot}"],    // Indicates the location of your .class files
            "options": [],                             // Additional options to pass to the java executable
            "args": []                                // Command line arguments to pass to the startup class
        }
    
    ],
    "compounds": []
    }
  3. Configure tasks.json:

{
    "version": "2.0.0",
    "type": "shell",
    "presentation": {
        "echo": true,
        "reveal": "always",
        "focus": false,
        "panel": "shared"

    },

    "isBackground": true,
    "tasks": [
        {

            "taskName": "build",
            "args": ["-g", "${file}"],
            "command": "javac"

        }
    ]
}
  1. Now debug any java file which accepts user inputs. VS Terminal won't be able to capture those inputs. Note: External console i.e. cmd works fine if I choose it to "externalConsole": true but not internal terminal.

Copied from original issue: Microsoft/vscode#34091

GorvGoyl commented 6 years ago

From @roblourens on September 10, 2017 19:25

I'm not sure what you mean by "VS Terminal won't be able to capture those inputs." Is that because it's not running the app in the integrated terminal? If so, this is a feature request for the extension.

GorvGoyl commented 6 years ago

VS terminal is the internal terminal of VS code. I've set the externalConsole": to false in launch.json but still i can't type anything in the terminal , i only see outputs of print statements. I'm not sure if this is the bug on extension side or your side. Your call.

GorvGoyl commented 6 years ago

From @Tyriar on September 11, 2017 17:6

I believe this is as designed, @isidorn can clarify

GorvGoyl commented 6 years ago

From @roblourens on September 11, 2017 17:20

Is it running in the terminal or the "debug console"?

GorvGoyl commented 6 years ago

when I debug a java file: In internal terminal(cmd) i see: >

Executing task: javac -g c:\Users\H213141\Documents\coding\console\java-debug\TestClass.java <

Terminal will be reused by tasks, press any key to close it.

but i can't provide user input here.

In debug console i see the program output ( i.e. System.out.println("provide some input:");) if any. But I can't provide any user input here. Although i can debug variables in debug console.

GorvGoyl commented 6 years ago

From @isidorn on September 13, 2017 8:46

This is as designed, for programs that need input please use the external terminal. There is probably already a feature request open that we start suporting user input in debug console / internal terminal. @weinand would know more

Closing as designed

GorvGoyl commented 6 years ago

VS Code does take user inputs from internal terminal when we "run" the code (Java,c++, python etc). The problem comes when we "debug" the code.

GorvGoyl commented 6 years ago

From @weinand on September 13, 2017 9:53

Please move the issue to the repository of the Java debugger you are using. VS Code provides no built-in Java functionality, so we do not know what the problem is.

You can move the issue with this tool: https://github-issue-mover.appspot.com

GorvGoyl commented 6 years ago

This issue was moved to DonJayamanne/javaVSCode#71