जावा के जेडीबी के साथ अपना कोड डिबग करना। मैं उस बिंदु पर फंस गया हूं जहां मेरा प्रोग्राम कमांड लाइन इनपुट की अपेक्षा करता है, लेकिन jdb इसे jdb कमांड के रूप में स्वीकार करता है।मैं jdb के बजाय चल रहे जावा प्रोग्राम में कंसोल इनपुट कैसे पास करूं?
मैं jdb को चल रहे प्रोग्राम में पाठ के माध्यम से कैसे पास करूं?
संस्करण:
C:\Documents and Settings\*snip*>java -showversion
java version "1.6.0_17"
Java(TM) SE Runtime Environment (build 1.6.0_17-b04)
Java HotSpot(TM) Client VM (build 14.3-b01, mixed mode, sharing)
संकलित:
javac -g LZWDecompress.java
jdb.ini:
stop in LZWDecompress.decompress
run
monitor list
ऐसा ही होता है:
Initializing jdb ...
*** Reading commands from C:\Documents and Settings\*snip*\jdb.ini
Deferring breakpoint LZWDecompress.decompress.
It will be set after the class is loaded.
> run LZWDecompress
Set uncaught java.lang.Throwable
Set deferred uncaught java.lang.Throwable
> > >
VM Started: Set deferred breakpoint LZWDecompress.decompress
File to be decompressed:
शीघ्र ऊपर में, मैं "परीक्षण" दर्ज करें, और यह प्रतिसाद प्राप्त:
...
VM Started: Set deferred breakpoint LZWDecompress.decompress
File to be decompressed: test
Unrecognized command: 'test'. Try help...
>
यहाँ समारोह मुख्य रूप से कोड है (...), हमारे प्रशिक्षक ने लिखा है, मुझे नहीं:
public static void main(String[] args) throws IOException {
short [] source;
int dlen;
int sz;
byte [] decompressed;
BufferedReader br;
DataInputStream In;
FileInputStream FI;
FileOutputStream FO;
InputStreamReader isr;
String cfnm;
String sfnm;
source = new short[INPUT_FILE_IO_BUFFER_SIZE];
decompressed = new byte[OUTPUT_FILE_IO_BUFFER_SIZE];
isr = new InputStreamReader(System.in);
br = new BufferedReader(isr);
System.out.print("File to be decompressed: ");
System.out.flush();
sfnm = br.readLine();
System.out.print("Name of the decompressed file: ");
System.out.flush();
cfnm = br.readLine();
FI = new FileInputStream(sfnm);
In = new DataInputStream(FI);
FO = new FileOutputStream(cfnm);
for (sz=0; true; ++sz) {
try { source[sz] = In.readShort();
} catch (EOFException e) { break;
} catch (Exception e) { System.out.print(e.toString());
}
}
dlen = decompress(source, sz, decompressed);
FO.write(decompressed, 0, dlen);
FO.close();
} // end main()
अरे टोफूबीर, स्पष्टीकरण (संपादन) के लिए धन्यवाद। जब आप कहते हैं "कमांड लाइन कंसोल के समान नहीं है!" क्या आपका कहना है कि एप्लिकेशन कब शुरू होता है, मैं कमांड लाइन के बजाय कंसोल के साथ बातचीत कर रहा हूं? मैंने पहले इस भेद के बारे में सोचा नहीं है, इसलिए मैं इसे लाने की सराहना करता हूं। धन्यवाद! : डी – iokevins