hi,
I want to use the scanner class for user I/O and I am
using Eclipse. But the when I import java.util.* , eclipse
doesnt recognize the scanner class. Can you please specifically
tell me what I should download and could you also give a direct
link which will get me use the scanner class??
Thanks,
mehmet
Eric Jacoboni - 18 Sep 2005 23:09 GMT
> I want to use the scanner class for user I/O and I am
> using Eclipse. But the when I import java.util.* , eclipse
> doesnt recognize the scanner class.
java.util.Scanner class comes with Java 5.0 : you cannot use it with
previous SDK.
> Can you please specifically
> tell me what I should download and could you also give a direct
> link which will get me use the scanner class??
I think that "Scanner class" in Google will give you all the answers
you need.
Here's a simple example:
import java.util.Scanner;
public class TestScanner {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.printf("Message : ");
String mess = scanner.nextLine();
System.out.printf("You wrote %s%n", mess);
}
}

Signature
Éric Jacoboni, né il y a 1430524940 secondes
Thomas Fritsch - 18 Sep 2005 23:27 GMT
> I want to use the scanner class for user I/O and I am
> using Eclipse. But the when I import java.util.* , eclipse
> doesnt recognize the scanner class.
Class java.util.Scanner is available since Java 1.5.
I suspect that your Eclipse project is configured to have an older Java (1.4
for example).
> Can you please specifically
> tell me what I should download and could you also give a direct
> link which will get me use the scanner class??
To change it: open the "Properties" dialog for your project, select "Java
Build Path" - "Library" - "Edit", select an JRE 1.5 (may be you'll have to
add the JRE 1.5 first)

Signature
"TFritsch$t-online:de".replace(':','.').replace('$','@')
mehmet canayaz - 19 Sep 2005 00:41 GMT
Hi again,
I updated my jre to 1.5 and eclipse doesn't give error messages for the
scanner class now.
But when I try to run it as an application, I am getting these kinda
messages
java.lang.NoClassDefFoundError: jre1/5/0_05
Exception in thread "main"
no matter which application I try to run.
now what :) ??
thanks for your answer
mehmet canayaz
mehmet canayaz - 19 Sep 2005 01:22 GMT
Everything is OK now, I just reinstalled Eclipse and it works
perfectly,
thanks again,
mehmet canayaz
Roedy Green - 19 Sep 2005 06:27 GMT
>java.lang.NoClassDefFoundError
see http://mindprod.com/jgloss/caq.html

Signature
Canadian Mind Products, Roedy Green.
http://mindprod.com Again taking new Java programming contracts.
ChrisWSU - 19 Sep 2005 14:24 GMT
That error is more then likely to occur when you have your run settings
screwed up, where its not actually tring run the right thing. Ive seen
that a lot...
Roedy Green - 18 Sep 2005 23:55 GMT
>hi,
>
[quoted text clipped - 6 lines]
>Thanks,
>mehmet
You would import java.util.Scanner;
not scanner.

Signature
Canadian Mind Products, Roedy Green.
http://mindprod.com Again taking new Java programming contracts.
Roedy Green - 18 Sep 2005 23:56 GMT
>I want to use the scanner class for user I/O and I am
>using Eclipse. But the when I import java.util.*
I believe it is new in 1.5, so make sure you have the recent JDK.
See http://mindprod.com/jgloss/jdk.html

Signature
Canadian Mind Products, Roedy Green.
http://mindprod.com Again taking new Java programming contracts.