Java의 jdb로 내 코드를 디버깅하십시오. 내 프로그램이 명령 행 입력을 기대하는 지점에 갇혀 있지만 jdb는 jdb 명령으로 가로 챈다.jdb 대신 실행중인 Java 프로그램에 콘솔 입력을 전달하는 방법은 무엇입니까?
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:
,536 하지 나, 여기
...
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()
Hey TofuBeer, (편집) 설명해 주셔서 감사합니다. "명령 줄이 콘솔과 다릅니다!"라고 말하면 응용 프로그램이 시작될 때 명령 줄 대신 콘솔과 상호 작용할 것이라고 말하는 것입니까? 나는 이전에이 구별에 대해 생각해 보지 않았으므로, 네가 가져다 주셔서 감사합니다. 감사! : D – iokevins