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 / First Aid / September 2006

Tip: Looking for answers? Try searching our database.

Cannot resolve symbol class Scanner

Thread view: 
Roy Gourgi - 27 Sep 2006 19:30 GMT
Hi,

I am trying to compile this program but I get the error message that it
cannot resolve this symbol Scanner. I downloaded the JDK6 and in my PATH
statement I put C:\Program Files\Java\jdk1.6.0\bin. The code is below. What
am I doing wrong.

TIA
Roy

import java.util.Scanner;

public class GetInteger

{

static Scanner sc = new Scanner(System.in);

public static void main(String[] args)

{

System.out.print("Enter an integer: ");

int i = GetInteger();

System.out.println("You entered "+i);

}

public static int GetInteger()

{

while (true)

{

try

{

return sc.nextInt();

}

catch (InputMismatchException e)

{

sc.next();

System.out.print("Thast not an integer. " + "try again");

}

}

}

}
Oliver Wong - 27 Sep 2006 19:42 GMT
> Hi,
>
[quoted text clipped - 5 lines]
> TIA
> Roy

[code snipped]

   Your code compiles fine on my side (except you forgot to import
InputMismatchException). Are you sure your environment is set up properly?
Are you able to compile and run a simple Hello World example?

   - Oliver
Roy Gourgi - 27 Sep 2006 21:32 GMT
Hi,

Yes I am able to compile the HelloWorld but I am still getting those error
messages that it cannot resolve both the Scanner and InputMismatchException.
Could it be that I do not have the java APIs???

Where is the the java.util API class located anyways?

Thanks
Roy

>> Hi,
>>
[quoted text clipped - 13 lines]
>
>    - Oliver
Roy Gourgi - 27 Sep 2006 21:52 GMT
Hi Oliver,

Maybe I do not have the latest API classes. I think that for Scanner and the
InputMatchingException you need the 1.5 API. Where can I download just the
API classes?

Thanks
Roy

> Hi,
>
[quoted text clipped - 57 lines]
>
> }
Petterson Mikael - 28 Sep 2006 08:40 GMT
Hi,

Do 'java -version'

Besides can you post the error message.

cheers,

//mikael

> Hi Oliver,
>
[quoted text clipped - 66 lines]
>>
>>}
Roy Gourgi - 28 Sep 2006 13:03 GMT
Hi,

It is version 1.6.0-beta2

I tried uninstalling java and now when I try to compile it I get the error
message:

'javac' is not recognized as an internal or external command, operable
program or batch file.

I guess I must have uninstalled the JDK?

How do I re-install it with all the API library classes included.

Thanks
Roy

> Hi,
>
[quoted text clipped - 76 lines]
>>>
>>>}
Petterson Mikael - 28 Sep 2006 13:35 GMT
Hi,

If you download and install jdk1.5.0_08 you will have them both.

http://java.sun.com/j2se/1.5.0/docs/api/index.html

Unless you have a specific reson to use Mustang java6.

cheers,

//mikael

> Hi,
>
[quoted text clipped - 93 lines]
>>>>
>>>>}
Roy Gourgi - 28 Sep 2006 15:42 GMT
Hi,

I installed the jdk1.5.0_08 and I still get the same error message???

How come?

Thanks
Roy

> Hi,
>
[quoted text clipped - 105 lines]
>>>>>
>>>>>}
Roy Gourgi - 28 Sep 2006 15:47 GMT
Hi,

I just fixed it, it was my path statement.

Thanks a lot for your help.

Roy

> Hi,
>
[quoted text clipped - 105 lines]
>>>>>
>>>>>}


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.