Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / July 2005

Tip: Looking for answers? Try searching our database.

input error I've never before encountered

Thread view: 
T-Storm - 19 Jul 2005 23:36 GMT
I recently reformatted my HDD, and subsequently reinstalled NetBeans IDE.
Now, none of my Java apps will function properly, because the system returns
the null value for all instances of System.in.  For example, the following
method simply prints on the screen, "null".  Does anyone know why?

public static void main(String[] args) throws IOException {
   BufferedReader test = new BufferedReader(new
InputStreamReader(System.in));
   String aLine = test.readLine();
   System.out.println(aLine);
}
--
Tom S.
Andrew Thompson - 19 Jul 2005 23:51 GMT
>  Does anyone know why?

I'd guess it has something to do with your IDE or it's
set-up.

You might try consulting
a) the manual/help supplied with it
b) the manufacturer.

( Unless, of course, you cannot run a 'HelloWorld'
example form the command line, in which case it
would more likely be a failed Java installation. )

Signature

Andrew Thompson
physci.org 1point1c.org javasaver.com lensescapes.com athompson.info
Filmed on Location

Patricia Shanahan - 19 Jul 2005 23:57 GMT
> I recently reformatted my HDD, and subsequently reinstalled NetBeans IDE.
> Now, none of my Java apps will function properly, because the system returns
[quoted text clipped - 9 lines]
> --
> Tom S.

The quoted program will print "null" if its standard input is empty.
test.readLine() returns null for end of file, and println prints a null
string as "null".

Is it possible that something changed to make input files empty?

Patricia
T-Storm - 20 Jul 2005 23:41 GMT
> The quoted program will print "null" if its standard input is empty.
> test.readLine() returns null for end of file, and println prints a null
> string as "null".
>
> Is it possible that something changed to make input files empty?

I haven't messed around with the BIOS or Windows settings (yet), so the
standard input device SHOULD be the keyboard.  I was also under the
impression that a simple System.in call defaulted to the keyboard in Java.

I'm going to attempt the suggestion of putting the readLine() call inside a
conditional loop, and I'll let you know if that solves the problem.
Otherwise, I'll be testing a "Hello, World!" programme from the command line
(another suggestion) and possibly reinstalling the JRE/JDK.
--
Tom S.
- - 20 Jul 2005 01:24 GMT
> I recently reformatted my HDD, and subsequently reinstalled NetBeans IDE.
> Now, none of my Java apps will function properly, because the system returns
[quoted text clipped - 8 lines]
> }
> --

Usually, the readLine() has to be in a loop if you want to continuously
read the input:

while ((aLine = test.readLine() != null) {
    System.out.println(aLine);
}

and the loop is in another thread.

Most likely your readLine() returns null.
T-Storm - 27 Jul 2005 00:17 GMT
Ok, I figured out the problem.  Java really dislikes the WindowsXP "Language
Bar."  Even if set to "English," Windows must be doing something
non-standard, because Java just won't accept anything inputted via the
keyboard.  Once I uninstalled the Language Bar, it worked fine.
Unfortunately, since I need to use Korean characters for several
applications, uninstalling it is not an option.  :-(  Thanks for all the
advice, though.  It was much appreciated.
--
Tom S.

>I recently reformatted my HDD, and subsequently reinstalled NetBeans IDE.
>Now, none of my Java apps will function properly, because the system
[quoted text clipped - 10 lines]
> --
> Tom S.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.