3

我是 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 设置任何路径设置吗?(我试图按照本教程进行操作)

我想我错过了一个非常基本的东西。试过谷歌,但同样的想法,但我无法解决问题。

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>java -version java version "1.6.0_45" Java(TM) SE Runtime Environment (build 1.6.0_45-b06) Java HotSpot(TM) Client VM (build 20.45-b01, mixed模式,分享)

C:\Users\test\workspace\sampleJava>javac -version javac 1.6.0_45

操作系统:Windows 7

4

1 回答 1

2

有同样的问题 - 似乎这是由于 jdk 安装在路径中有空格的文件夹中,即“程序文件” - 将 jdk 安装移动到 c:\jdk 并且问题消失了。

于 2013-05-25T16:30:45.453 回答