JDWP syntax error when using Powershell

debugging, java, powershell, remote-debugging, windows

Solution

Can you try :

PS> $a = "java -Xdebug -Xrunjdwp:server=y,transport=dt_socket,address=4000,suspend=n <application>"
PS> Invoke-Expression $a

I suppose PowerShell try to interpret something in your command line. This way PowerShell just have to execute. Be carefulk, if you have double quotes in your application name use ` before.

You can also try this in order to paramter your call.

$scriptBlock = {java -Xdebug                                                         <# This is comment param 1 #>`
                     -Xrunjdwp:server=y,transport=dt_socket,address=4000,suspend=n   <# This is comment param 1 #>`
                     `"$($args[0])`"}                                                <# Application Path #>

$ApplicationName = "c:\un chemin applicatif\toto"
Invoke-Command -ScriptBlock $scriptBlock  -ArgumentList $ApplicationName

I found it, just try :

PS> $a = "java -Xdebug '-Xrunjdwp:server=y,transport=dt_socket,address=4000,suspend=n' <application>"

I just inclose -Xrunjdwp param inside ''.

Problem

Windows 7 x64 and the newest java version (didn't work any better with u21 though) ``` java version "1.7.0_25" Java(TM) SE Runtime Environment (build 1.7.0_25-b17) Java HotSpot(TM) 64-Bit Server VM (build 23.25-b01, mixed mode) ``` When trying to start a java application to debug it remotely I get the following error: ``` java -Xdebug -Xrunjdwp:server=y,transport=dt_socket,address=4000,suspend=n <application> ERROR: JDWP option syntax error: -agentlib:jdwp=server=y transport=dt_socket address=4000 suspend=n ``` but only when using PowerShell, running the exact same command with cmd.exe works just as expected.

Original source