I am new to debugging with jdb
I wrote the folowing program
from TIJ3(thinking in java) book and I save it
X1:SimpleDebugging.java
// {ThrowsException}
public class SimpleDebugging {
private static void foo1() {
System.out.println("In foo1");
foo2();
}
private static void foo2() {
System.out.println("In foo2");
foo3();
}
private static void foo3() {
System.out.println("In foo3");
int j = 1;
j--;
int i = 5 / j;
}
public static void main(String[] args) {
foo1();
}
} ///:~
then I compile it with
"javac -g SimpleDebugging.java"
then to debug my program I
say:
"jdb SimpleDebugging"
then
jdb says:
"Initializing jdb...
>"
then I say
"catch Exception"
it answers
"Deferring exception catch Exception.
It will be set after the class is loaded.
>"
then I command to run
"run"
and it answers
"run SimpleDebugging
java.net.UnknownHostException: localhost.localdomain
at java.net.InetAddress.getAllByName0(InetAddress.java:571)
at java.net.InetAddress.getAllByName0(InetAddress.java:540)
at java.net.InetAddress.getAllByName(InetAddress.java:533)
at java.net.InetAddress.getLocalHost(InetAddress.java:723)
at com.sun.tools.jdi.SocketTransport.startListening(SocketTransport.java:94)
at com.sun.tools.jdi.SocketTransport.startListening(SocketTransport.java:89)
at com.sun.tools.jdi.SunCommandLineLauncher.launch(SunCommandLineLauncher.java:116)
at com.sun.tools.example.debug.tty.VMConnection.launchTarget(VMConnection.java:266)
at com.sun.tools.example.debug.tty.VMConnection.open(VMConnection.java:134)
at com.sun.tools.example.debug.tty.Commands.commandRun(Commands.java:398)
at com.sun.tools.example.debug.tty.TTY.executeCommand(TTY.java:393)
at com.sun.tools.example.debug.tty.TTY.(TTY.java:625)
at com.sun.tools.example.debug.tty.TTY.main(TTY.java:924)
Fatal error:
Unable to launch target VM.
"
and it dies.
I don't know what should I do please help me
I can't run jdb for anny programm still now.
"OS: redhat linux 7.3
java compiler: java version "1.3.1"
Java(TM) 2 Runtime Environment, Standard Edition (build Blackdown-1.3.1-FCS)
Java HotSpot(TM) Client VM (build Blackdown-1.3.1-FCS, mixed mode)"