On Fri, 19 Feb 1999 [EMAIL PROTECTED] wrote:
> Greetings,
>
> I'm having problems running java from within a shell script. The java
> application mostly runs, but I've noticed that it does not receive a
> ^C interrupt and it cannot read from stdin when invoked this way.
> Typing "java ..." directly at my bash prompt does not demonstrate
> this problem. Any ideas?
>
> I'm running Linux kernel 2.0.36 (RedHat 5.2) with Blackdown's JDK
> 1.1.7_v1a. The following little class demonstrates the problem...
>
>
> import java.io.*;
>
> class input
> {
>
> public static void main(String[] argv)
> {
> BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
>
> try {
> while (true) {
> String line = in.readLine();
> if (line == null) break;
> System.out.println(line);
> }
> } catch (Exception e) {
> e.printStackTrace();
> }
> }
> }
>
>
> And here's a simple shell script...
>
> #!/bin/sh
>
> java -classpath $CLASSPATH input
>
>
I ran into this same problem. I too posted a note to the mailing list
but I did not hear back from anyone. The really odd part was that it
only seemed to happen when running with native threads. If I ran the
green threads version it worked just fine. Another strange thing that
seemed to happen with that native threads version is that reading
from System.in did not work when java was invoked from a shell script.
Mo DeJong
dejong at cs.umn.edu