DonJayamanne / javaVSCode

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

tasks.json configure problem and handshake failed problem #77

Open qianch3n opened 7 years ago

qianch3n commented 7 years ago

Hi,

I am very new to Java. And I really like vscode. So I have tried to config this Java debugger for quit a while. But still can't make it. My laptop is windows 10 64bit.

My project tree is just like:

project
    .vscode
    test.java
    test.class

Launch.json

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Debug Java",
            "type": "java",
            "request": "launch",
            "externalConsole": true,                //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": []
}

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"
        }
    ]
}

When I try to launch debug, I got errors as below:

> Executing task: javac -g d:\atom-projects\leetcode-solutions\java-solutions\JavaPlayground.java <

javac: file not found: d:atom-projectsleetcode-solutionsjava-solutionsJavaPlayground.java
Usage: javac <options> <source files>
use -help for a list of possible options
The terminal process terminated with exit code: 2

The backslash dosen't get escaped.

Then I tried to change the ${file} to the actual directory as d:\atom-projects\leetcode-solutions\java-solutions\${fileBasename}. It worked but it came to problem in a command window showing Debugger failed to attach: handshake failed - connection prematurally closed.

The problems could be trivial but I really don't know how to fix it. Thank you very much for your time. Look forward to your reply. : )

faustinoaq commented 7 years ago

Very similar issue here :point_right: https://github.com/DonJayamanne/javaVSCode/issues/17#issuecomment-257095778

Also check other issues, maybe this was already solved by other user :wink:

qianch3n commented 7 years ago

The first problem is solved by switching the shell back to windows powershell as I was using bash instead before. Windows uses\, yet bash uses /.

But still don't know how to solve the handshake failed problem.