我是java和jdb的新手,尝试调试示例程序:
Foo.java
class Foo {
public static void main(String[] args){
System.out.println("Chexking dalvik virtual machine on system");
}
}
compiled it with -g flag . javac -g Foo.java
compiled properly .
Tried to run program using command >java Foo
Got the output .
Then tried to run : jdb Foo
C:\Users\test\workspace\sampleJava>jdb Foo
Initializing jdb ...
> stop in Foo.main
Deferring breakpoint Foo.main.
It will be set after the class is loaded.
> run main
run main
java.io.IOException: Cannot run program "C:\Program": CreateProcess error=2, The system cannot find the file specified
at java.lang.ProcessBuilder.start(ProcessBuilder.java:470)
at java.lang.Runtime.exec(Runtime.java:593)
at java.lang.Runtime.exec(Runtime.java:466)
at com.sun.tools.jdi.AbstractLauncher$Helper.launchAndAccept(AbstractLauncher.java:162)
at com.sun.tools.jdi.AbstractLauncher.launch(AbstractLauncher.java:114)
at com.sun.tools.jdi.SunCommandLineLauncher.launch(SunCommandLineLauncher.java:217)
at com.sun.tools.example.debug.tty.VMConnection.launchTarget(VMConnection.java:334)
at com.sun.tools.example.debug.tty.VMConnection.open(VMConnection.java:166)
at com.sun.tools.example.debug.tty.Commands.commandRun(Commands.java:589)
at com.sun.tools.example.debug.tty.TTY.executeCommand(TTY.java:474)
at com.sun.tools.example.debug.tty.TTY.<init>(TTY.java:707)
at com.sun.tools.example.debug.tty.TTY.main(TTY.java:1011)
Caused by: java.io.IOException: CreateProcess error=2, The system cannot find the file specified
at java.lang.ProcessImpl.create(Native Method)
at java.lang.ProcessImpl.<init>(ProcessImpl.java:177)
at java.lang.ProcessImpl.start(ProcessImpl.java:28)
at java.lang.ProcessBuilder.start(ProcessBuilder.java:452)
... 11 more
Fatal error:
Unable to launch target VM.
据我所知:jdb无法加载该类。我需要为jdb设置任何路径设置。 (我试图遵循这个tutorial)
我想我错过了一件非常基本的事情。尝试谷歌,但同样的想法,但我无法解决问题。
My PATH=%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;C:\cygwin\;C:\Users\test\Downloads\adt-bundle-windows-x86-20130219\adt-bundle-windows-x86-20130219\sdk\platform-tools\;"C:\Program Files\Java\jre1.6.0_16\bin";"C:\Program Files\Java\jre6\bin";"C:\Program Files\Java\jdk1.6.0_45\bin";C:\Users\test\Downloads\adt-bundle-windows-x86-20130219\adt-bundle-windows-x86-20130219\sdk\tools;"C:\Program Files\Graphviz2.26.3\bin";"C:\Program Files\Graphviz2.26.3\bin"
C:\ Users \ test \ workspace \ sampleJava&gt; java -version java版“1.6.0_45” Java(TM)SE运行时环境(版本1.6.0_45-b06) Java HotSpot(TM)客户端VM(版本20.45-b01,混合模式,共享)
C:\ Users \ test \ workspace \ sampleJava&gt; javac -version javac 1.6.0_45
操作系统:Windows 7
答案 0 :(得分:2)
出现同样的问题 - 似乎是因为jdk安装在路径中有空格的文件夹中,即“Program Files” - 将jdk安装移动到c:\ jdk,问题就消失了