|
-
Nov 23rd, 2004, 04:30 PM
#1
Thread Starter
Addicted Member
Scanner Error
Hello.
I am using Netbeans 4.0 Beta 2 with JDK 1.5. With this simple, short code I am generating an error that I can't seem to figure out.
Code:
import java.util.*;
public class Main
{
public static void main (String [] args)
{
Scanner input = new Scanner(System.in);
String myName = input.next();
System.out.println(myName);
}
}
It builds fine, however when I run the program it generates this error message.
Code:
Exception in thread "main" java.util.NoSuchElementException
at java.util.Scanner.throwFor(Scanner.java:817)
at java.util.Scanner.next(Scanner.java:1317)
at Main.main(Main.java:8)
Java Result: 1
Has anyone encountered this. I have reinstalled Netbeans and the JDK several times, but it still doesn't work.
Thanks for any help.
Pete
Last edited by Peter1; Dec 3rd, 2004 at 05:07 AM.
-
Nov 27th, 2004, 03:11 PM
#2
Thread Starter
Addicted Member
-
Nov 28th, 2004, 02:55 PM
#3
Apparently my beta JDK version doesn't have any of the Scanner constructors...
Will test as soon as I get the new version installed.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Nov 28th, 2004, 03:31 PM
#4
Thread Starter
Addicted Member
Thanks.
I've installed the Netbeans Release Candidate, but it still doesn't work. So I don't think its that.
-
Dec 3rd, 2004, 05:06 AM
#5
Thread Starter
Addicted Member
Re: Scanner Error
Turns out it probably was Netbeans. I installed wordpad and used that to compile the program and it works fine. Switch over to Netbeans and it still doesn't work.
-
Jan 15th, 2005, 04:20 AM
#6
New Member
Re: Scanner Error
I aslo meet this trouble like you, can anyone help out of this?
-
Jan 15th, 2005, 08:17 AM
#7
Frenzied Member
Re: Scanner Error
This compiles and runs fine for me. I know serveral people have had weird errors while running netbeans.
ansi, are you running netbeans also?
Note: You might could try input.close(); after teh System.outprintln() statement. Don't know if this will work or not.
-
Jan 17th, 2005, 08:32 AM
#8
New Member
Re: Scanner Error
Of course, I use Netbeans 4.0 with jdk1.5.0.
I have try your idea but i still don't work.
The most interesting thing is it's ok with another editor program even if the command prompt. Does Netbeans conflict with my computer????
I hope you can help us!!!
-
Jan 17th, 2005, 09:24 AM
#9
Frenzied Member
Re: Scanner Error
Netbeans is known to have some weird problems. At my school, my teacher tried to compile a simple hello world app, but it came up some weird stuff that wasn't even in the program.
Personally, I would just switch to a different IDE, but if you insist on keeping it, I guess you coud stay with it.
So it works with other editors using the command line....
Try using a different IDE like JCreator, BlueJ, or something simple that will let you compile and run the program. If you try this, let me know the results. If it compiles and runs fine, then something's up with netbeans.
I think I might download netbeans and try it out.
NOTE: DID YOU DOWNLOAD AND INSTALL THE NETBEANS VERSION THAT WAS BUNDLED WITH THE JDK?
-
Jan 17th, 2005, 09:36 AM
#10
Frenzied Member
Re: Scanner Error
Do you know what JRE netbeans is using?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|