Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Newcomers » Newcomers » Problems with Java Scanner on Eclipse..(Eclipse dont recognize Java Scanner)
Problems with Java Scanner on Eclipse.. [message #508112] Sat, 16 January 2010 00:41 Go to next message
Esa is currently offline EsaFriend
Messages: 4
Registered: January 2010
Location: Pori, Finland
Junior Member

Hello! I'm new in here.

My problem is the Scanner in Java, Eclipse canot resolve it. I am using JRE 1.5 on Eclipse but i have Java 1.6 installed on my system. Somehow eclipse dont seem to find it, at least it is not on the list at the settings.

Im having my Java exam in two weeks so i should really get this thing working.. What could be wrong? Since i'm new to eclipse i could have left something unnoticed..?
Re: Problems with Java Scanner on Eclipse.. [message #508116 is a reply to message #508112] Sat, 16 January 2010 02:00 Go to previous messageGo to next message
Olivier Thomann is currently offline Olivier ThomannFriend
Messages: 518
Registered: July 2009
Senior Member
Le 2010-01-15 19:41, Esa a écrit :
> My problem is the Scanner in Java, Eclipse canot resolve it. I am using
> JRE 1.5 on Eclipse but i have Java 1.6 installed on my system. Somehow
> eclipse dont seem to find it, at least it is not on the list at the
> settings.
>
> Im having my Java exam in two weeks so i should really get this thing
> working.. What could be wrong? Since i'm new to eclipse i could have
> left something unnoticed..?
Could you please at least give a code snippet that is not working and
tell us what kind of errors do you have.
--
Olivier
Re: Problems with Java Scanner on Eclipse.. [message #508126 is a reply to message #508112] Sat, 16 January 2010 10:30 Go to previous messageGo to next message
Esa is currently offline EsaFriend
Messages: 4
Registered: January 2010
Location: Pori, Finland
Junior Member

oh yes, sorry about not posting this code.

import java.util.Scanner;

public class testi
{
public static void main(String[] args)
{

int luku;
Scanner lukija = new Scanner(System.in);

System.out.println("Anna luku: ");
luku = lukija.nextInt();
System.out.println("\n"+luku);
}
}

Error:
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
Scanner cannot be resolved to a type
Scanner cannot be resolved to a type

at testi.main(testi.java:7)
Re: Problems with Java Scanner on Eclipse.. [message #508145 is a reply to message #508126] Sat, 16 January 2010 14:34 Go to previous messageGo to next message
GCampton  is currently offline GCampton Friend
Messages: 12
Registered: January 2010
Junior Member
What about other imports like math or file ?

you may need to go to preferences -> java -> complier -> check that it's ok
and preferences -> java -> Installed JRE

Re: Problems with Java Scanner on Eclipse.. [message #508158 is a reply to message #508112] Sat, 16 January 2010 21:09 Go to previous messageGo to next message
Esa is currently offline EsaFriend
Messages: 4
Registered: January 2010
Location: Pori, Finland
Junior Member

The compiler compliance level is 5.0 and installed JRE is java-1.5.0-gcj-4.3-1.5.0.0

I have imported Date from the utils and Math, those worked fine. I tried to use import Java.util.*; but Scanner didn't work.
Re: Problems with Java Scanner on Eclipse.. [message #508162 is a reply to message #508158] Sat, 16 January 2010 21:26 Go to previous messageGo to next message
David Wegener is currently offline David WegenerFriend
Messages: 1445
Registered: July 2009
Senior Member
Esa wrote:
> The compiler compliance level is 5.0 and installed JRE is
> java-1.5.0-gcj-4.3-1.5.0.0
>
> I have imported Date from the utils and Math, those worked fine. I tried
> to use import Java.util.*; but Scanner didn't work.
Use a Sun jdk instead of gcj.
Re: Problems with Java Scanner on Eclipse.. [message #508214 is a reply to message #508112] Sun, 17 January 2010 17:42 Go to previous messageGo to next message
Esa is currently offline EsaFriend
Messages: 4
Registered: January 2010
Location: Pori, Finland
Junior Member

ok, now i can compile it from the console.. but i cannot change it from eclipse? eclipse only has the gjc option on the installed JRE's..
Re: Problems with Java Scanner on Eclipse.. [message #508220 is a reply to message #508214] Sun, 17 January 2010 18:41 Go to previous messageGo to next message
David Wegener is currently offline David WegenerFriend
Messages: 1445
Registered: July 2009
Senior Member
Esa wrote:
> ok, now i can compile it from the console.. but i cannot change it from
> eclipse? eclipse only has the gjc option on the installed JRE's..
Add the Sun jdk in the Windows->Preferences->Java->Installed JRE page.
Re: Problems with Java Scanner on Eclipse.. [message #509258 is a reply to message #508220] Thu, 21 January 2010 14:18 Go to previous message
Eric Rizzo is currently offline Eric RizzoFriend
Messages: 3070
Registered: July 2009
Senior Member
On 1/17/10 1:41 PM, David Wegener wrote:
> Esa wrote:
>> ok, now i can compile it from the console.. but i cannot change it
>> from eclipse? eclipse only has the gjc option on the installed JRE's..
> Add the Sun jdk in the Windows->Preferences->Java->Installed JRE page.

You really should be running Eclipse under the Sun JDK. Install it and
then set up your eclipse.ini as described here:
http://wiki.eclipse.org/Eclipse.ini

Hope this helps,
Eric
Previous Topic:Eclipse C++ Missing Something?
Next Topic:Memory View in Eclipse
Goto Forum:
  


Current Time: Thu Apr 18 00:06:22 GMT 2024

Powered by FUDForum. Page generated in 0.02798 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top