This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Java Interview Guide and have Anthony DePalma on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "" The handle is invalid" in Win 2000" Watch "" The handle is invalid" in Win 2000" New topic

" The handle is invalid" in Win 2000

Eric Knapp

Joined: May 06, 2001
Posts: 4
I am in instructor at a community college and I have many students who can't get something to work under Windows 2000 with
jdk1.3. They are trying to perform a simple and they get this: The handle is invalid
at Method)
at Demo.main(
Exception in thread "main"
I can't reproduce this on my Linux box and the students in the class who are running Windows 98 also are not having any problems.
Can anyone help?
John Dale
Ranch Hand

Joined: Feb 22, 2001
Posts: 399
Just for grins, I tried to reproduce on Windows NT4 workstation SP6a, with
java version "1.3.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0-C)
Java HotSpot(TM) Client VM (build 1.3.0-C, mixed mode)
I tried witih input from console, redirect from text file, and pipe from text file. All worked. However, I see something I didn't expect for input from the console, which may be evidence of a problem in the Java library that might lead to system-dependent results.
Windows NT 4, as have its ancestors back to at least CP/M, treats a line beginning with control-Z as an end of file indication. And as expected, when reading from, typing
causes to return -1. However, if you issue another, it blocks instead of returning -1 immediately (which is what it returns when reading from a file or pipe). So the Java library seems to be asking the OS for another octet even though it is already recognized the end of file. If you now type <letter><Enter>, read() returns the code for the letter you typed, instead of -1.
This suggests to me that the Java reading from the console after it has already indicated EOF. Perhaps the results of this is different for Win2000 than for NT4 or Win98.
In case it is of interest, here is my test program. Can anyone see a flaw in my obsevation?
class SystemInReadTest {
public static void main(String[] args) throws IOException {
while ( != -1)
{ }
System.out.println("Got EOF, reading again gives...");
[This message has been edited by John Dale (edited May 06, 2001).]
Cindy Glass
"The Hood"

Joined: Sep 29, 2000
Posts: 8521
Apparently you need to install the service pack 1 (sp1) to fix a few problems in win2000.
This has a link to the download.

"JavaRanch, where the deer and the Certified play" - David O'Meara
I agree. Here's the link:
subject: " The handle is invalid" in Win 2000
It's not a secret anymore!