HP3000-L Archives

March 2000, Week 2

HP3000-L@RAVEN.UTC.EDU

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
Jon Diercks <[log in to unmask]>
Reply To:
Jon Diercks <[log in to unmask]>
Date:
Wed, 8 Mar 2000 16:53:45 -0500
Content-Type:
text/plain
Parts/Attachments:
text/plain (126 lines)
Mike & Pascal (what an ironic name for a Java programmer! ;> )

It is a buffer problem, and it is not limited to DTCs. This was done on an NS/VT connection:

shell/iX: java -fullversion
java full version "JDK 1.1.7B (MPE Version A.17.02 GT JIT)"
shell/iX: cat Greetings.java
import java.io.*;

class Greetings {
        public static void main(String[] args) throws IOException {
        BufferedReader cin = new BufferedReader(new InputStreamReader(System.in));
        System.out.println("What is your name?");
        String name = cin.readLine();
        System.out.println("Bonjour " + name);
        }
}
shell/iX: cat Greeting1.java
import java.io.*;

class Greeting1 {
        public static void main(String[] args) throws IOException {
        DataInputStream cin = new DataInputStream(System.in);
        System.out.println("What is your name?");
        String name = cin.readLine();
        System.out.println("Bonjour " + name);
        }
}
shell/iX: java Greetings
What is your name?
Jon

:eod
Bonjour Jon
shell/iX: java Greeting1                                                       
What is your name?
Jon
Bonjour Jon
shell/iX: 

>>>
From:         Mike Yawn <[log in to unmask]>

Pascal,

This is a known problem in the JDK when dealing with DTC-connected
terminals (or the console).  Running the same code over a VT or
telnet connection works as expected.

We have a fix currently in testing for this, but only for
JDK 1.2.2, so you would need to upgrade to that version to get
the lastest HPI library with the fix.  Contact me if you want
to get a copy; it is not yet publicly available through Jazz
or the response centers.

It's possible, although I haven't actually tested it, that
the code might also work if you omitted the 'BufferedReader'
class and just read directly from the InputStreamReader,
as the problem resides in the buffering code.

Mike

Pascal Luyckx ([log in to unmask]) wrote:
: I have a problem executing the following Java code on an MPE/iX 6.0
: machine :

: import java.io.*;

: class MyJavaTest
: {
:  public static void main(String args[])
:  {
:   String firstOne = getString("First one: ");
:   String secondOne = getString("Second one: ");
:   System.out.println("firstOne=" + firstOne);
:   System.out.println("secondOne=" + secondOne);
:  }

:  private static String getString(String prompt)
:  {
:  BufferedReader in = new BufferedReader(new InputStreamReader
: (System.in));
:   if (prompt != null)
:    System.out.print(prompt);

:   String rString = "";
:   try
:    { rString = in.readLine(); }
:   catch (Exception e)
:    { rString = ""; }
:   return rString;
:  }
: }

: When I run this program, I get the "First one:" prompt as expected. When I
: enter some data and the press the return key I don't get the second prompt.
: I guess that the program is still in the first getString. When I run this
: code on a PC, the program behaves normal. Has anybody seen this before? My
: Java version is :

: java full version "JDK 1.1.7B:03/20/99-09:03 (MPE Version A.17.03 GT JIT)"

: Regards

: Pascal Luyckx
: Cheops technology nv
: Jozef Verbovenlei 91
: 2100 Antwerp
: Belgium
: Phone: +32 3 366 50 30
: Fax: +32 3 366 57 35


--
-----------------------------------------------------------------
Mike Yawn
Hewlett-Packard                      email       [log in to unmask]
Commercial Systems Division          Voice         (408) 447-4367
19447 Pruneridge Ave M/S 47UA        Fax           (408) 447-4441
Cupertino, CA  95014
-----------------------------------------------------------------

____________________________________________________
Jon Diercks  ---  AU Information Technology Services
[log in to unmask] --- http://users.anderson.edu/~jon/

ATOM RSS1 RSS2