Skip to content
This repository has been archived by the owner on Nov 10, 2017. It is now read-only.

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

Closed
GorvGoyl opened this issue Sep 13, 2017 · 14 comments
Closed

Comments

@GorvGoyl
Copy link

From @JerryGoyal on September 10, 2017 6:45

  • VSCode Version: 1.16
  • OS Version: Win10

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": []
}
  1. 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
Copy link
Author

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
Copy link
Author

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
Copy link
Author

From @Tyriar on September 11, 2017 17:6

I believe this is as designed, @isidorn can clarify

@GorvGoyl
Copy link
Author

From @roblourens on September 11, 2017 17:20

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

@GorvGoyl
Copy link
Author

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
Copy link
Author

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
Copy link
Author

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
Copy link
Author

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
Copy link
Author

Hi, seems like this issue is related to the java debugger extension. So I moved it from Microsoft/VSCode to your repo. Could you please take a look.

@faustinoaq
Copy link
Contributor

Please, next time comment just one, because one comment is one mail, I was a bit scared to see so many mails 😅

And yeah, Java Debugger doesn't support integrated terminal yet, if you want to contribute send a PR 😄

@GorvGoyl
Copy link
Author

Didn't mean to scare you :D Actually, I used some issue migrator tool to migrate this issue from Microsoft repository and it included previous comments too, hence the email bombardment :P

@weinand
Copy link

weinand commented Sep 13, 2017

@faustinoaq supporting the VS Code integrated terminal is trivial since VS Code is doing all the heavy lifting for you. From the debug adapter just use the "runInTerminalRequest" and pass the command line arguments. See here how this is done for node-debug.

@faustinoaq
Copy link
Contributor

Oh, I see. Thanks you for the node-debug reference 👍

@faustinoaq
Copy link
Contributor

Keep discussion here 👉 #67

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants