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

handshake failed-- need help #53

Closed eric2877 closed 7 years ago

eric2877 commented 7 years ago

My system is win10 x64 when I am tring to debug helloworld.java, it always failed at the beginning, cmd : Listening for transport dt_socket at address: 52414 Debugger failed to attach: handshake failed - connection prematurally closed so I start the server manully in cmd as you suggested in an answer.

PS D:\Document\VScode\Java\src\com\liu\little> java -agentlib:jdwp=transport=dt_socket,server=y,address=4711 Helloworld Listening for transport dt_socket at address: 4711 Debugger failed to attach: handshake failed - received >Content-Length< - expected >JDWP-Handshake< Debugger failed to attach: handshake failed - received >Content-Length< - expected >JDWP-Handshake< Debugger failed to attach: handshake failed - received >Content-Length< - expected >JDWP-Handshake<

launch.json "version": "0.2.0",

"configurations": [
    {
        "name": "Java",
        "type": "java",
        "request": "launch",
        "stopOnEntry": true,
        "jdkPath": "${env:JAVA_HOME}/bin",
        "cwd": "${workspaceRoot}/src",
        "startupClass": "com.liu.little.${fileBasenameNoExtension}",
        "classpath":[
            ".",
          "${workspaceRoot}/bin/com/liu/little"
        ],
        "preLaunchTask": "build"
       // "debugServer": 4711
    }

]

tasks.json "version": "0.1.0",

        "isShellCommand": true,
        "showOutput": "always",
        "suppressTaskName": true,
        "tasks": [
            {
                "taskName": "build",
                "command": "javac",
                "args": ["-g", "${file}","-classpath","${workspaceRoot}/bin","-encoding","GBK","-d","${workspaceRoot}/bin"],
                "isBuildCommand": true
            },
faustinoaq commented 7 years ago

classpath option was added recently, it isn't published on marketplace yet. see: https://github.com/DonJayamanne/javaVSCode/commit/ee0fcb3ce1e9cbf69e81c8e8e4d3290b66107a7a

Instead, You can clone this repo in your extensions folder and do npm install inside it.

@DonJayamanne will publish it in his free time.

eric2877 commented 7 years ago

thanks for your reply,i did npm install (in addition, the package.json file lost a "," in line 183), and compiled all ts files to js in my extensions folder, when i debug java, nothing happended, except a bar at the top of the window with only stop button available.

if i use the attribuilt "externalConsole": true, see the message below in cmd Listening for transport dt_socket at address: 54497 Debugger failed to attach: handshake failed - connection prematurally closed

launch.json "version": "0.2.0", "configurations": [

    {
        "name": "Java",
        "type": "java",
        "request": "launch",
        "stopOnEntry": true,
        "jdkPath": "${env:JAVA_HOME}/bin",
        "cwd": "${workspaceRoot}",
        "startupClass": "HelloWorld",
        "classpath": [
            ".",
            "${workspaceRoot}/bin"
        ],
        "externalConsole": true
    },

I really don't know what's wrong with it, my nodejs version is v8.1.3, window 10 1607 X64,

eric2877 commented 7 years ago

Then, I click the stop button, after than, the command line output the "helloworld", it's so weird.

Listening for transport dt_socket at address: 56950 Debugger failed to attach: handshake failed - connection prematurally closed ERROR: transport error 202: recv error: Connection reset by peer Listening for transport dt_socket at address: 56950 helloworld

faustinoaq commented 7 years ago

I can see that message too, I think is a bug :sweat_smile:

eric2877 commented 7 years ago

all right, I believe the next release will be much better, Thanks for your patience

faustinoaq commented 7 years ago

See #8