> Well first off this is probably a better question for a Java list.
> But I'll answer so if someone checks the archive again they'll find an
> answer.
> It is probably one of two things if I understand your question
> correctly.
Sorry, it looks as if I haven't been clear enough in my question. I'm
convinced that this is relevant to the JDE list.
My java programs work fine when run in ordinary shells, and they work
fine when I run them using JDE + comint in emacs under unix. But when
I try to run them using JDE + comint under NT, all echoing bar the
first is wrong.
In more detail:
Here is a simple program, shamelessly pinched from one of the much
older posts on this list trying to explain the same problem:
import java.io.*;
public class Echo {
public static void main(String[] args) throws IOException {
BufferedReader in =
new BufferedReader(new InputStreamReader(System.in));
for(;;) {
System.out.print("> ");
String line = in.readLine();
if ((line == null) || line.equals("quit"))
break;
System.out.println(line);
}
}
}
In normal circumstances, the results of running this look like:
> 1
1
> hello
hello
> fred
fred
> quit
and so on.
Running this program using C-c C-v C-r, using JDE and NTEmacs I get
something like
> 1
hello
fred
quit
1
> hello
> fred
> quit
It looks like the input and output buffers are not being flushed until
the program terminates.
I've tried
System.out.println(line); System.out.flush();
but
(a) it doesn't seem to help; and
(b) I shouldn't have to change my program to suit the environment.
I think (but I'm not sure) that the following from the NTEmacs FAQ is
relevant:
--begin quote--
Buffering in shells
You may notice that some programs, when run in a shell in shell-mode,
have their output buffered (e.g., people have found this happening to
them with sql-mode). When the program has a lot of output, it
overflows the buffering and gets printed to the shell buffer; however,
if the program only outputs a small amount of text, it will remain
buffered and won't appear in the shell buffer.
Although it may at first seem like the shell is buffering the output
from the program, it is actually the program that is buffering
output. The C runtime typically decides how to buffer output based
upon whether stdout is bound to a handle to a console window or
not. If bound to a console window, output is buffered line by line; if
bound to a block device, such as a file, output is buffered block by
block.
In a shell buffer, stdout is a pipe handle and so is buffered in
blocks. If you would like the buffering behavior of your program to
behave differently, the program itself is going to have to be changed;
you can use setbuf and setvbuf to manipulate the buffering semantics.
--end quote--
Does anybody have any ideas?
We want to use JDE + NTEmacs for teaching beginning programming. Many
of our early exercises and examples use this type of simple IO, so
some sort of solution is very important to us.
--
Gilbert Laycock email: [EMAIL PROTECTED]
Maths and Computer Science, http://www.mcs.le.ac.uk/~glaycock
Leicester University phone: (+44) 116 252 3902