• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Accessing the java.util.Scanner Utility

 
Benjamin Chau
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Question about using the older versions of Java:

I think this is the version of my Java development kit software: j2sdk1.4.2_13

Since this is an older version I've been told that I don't have certain utilities such as the java.util.Scanner. Is this true or am I just not accessing the utility correctly in the development kit?

When I move the development kit to the right directory to coordinate with my Environment Variable, the program can still not access the Scanner utility.
 
Joanne Neal
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you go the javadoc for the Scanner class (or any class for that matter) and then go to the end of the description section (just before the list of constructors) you will see something like
Since:
1.5
This is the earliest version of Java that the class is in. If there is no entry like this, then the class has always been in the API.
 
Varun Chopra
Ranch Hand
Posts: 213
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Since this is an older version I've been told that I don't have certain utilities such as the java.util.Scanner. Is this true or am I just not accessing the utility correctly in the development kit?


This is true. If you look at javadoc for java.util.Scanner class (http://java.sun.com/j2se/1.5.0/docs/api/java/util/Scanner.html), and search 'Since' on that page, you would see 1.5 written there. That means this class was added in jdk 1.5 version.
 
Campbell Ritchie
Sheriff
Posts: 48382
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Now that you know how to set up a PATH, you can download a newer version of Java from the Downloads site. You want the one called Java SE Development Kit (JDK) 6 Update 10, and the corresponding PATH entry will read something like

C:\Program Files\Java\jdk1.6.0_10\bin

if you use the default location. Remember it is called development kit, not runtime environment.

Once you have got that working, you will have the Scanner class available.
 
Benjamin Chau
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks All!

Campbell, I may need your help if I can't figure out how to set the Environment Variable correctly for the new install. If you I do the steps like last time, maybe it'll go smoothly but we'll see...

<keeping fingers crossed>
 
Gamini Sirisena
Ranch Hand
Posts: 378
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That since bit never registered for me to find in which version a Class was included.

But here's the bummer.. the JSE 5 docs say since 1.5 and JSE 6 docs say since 1.6.. whom are we to believe?
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24208
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Gamini Sirisena:

But here's the bummer.. the JSE 5 docs say since 1.5 and JSE 6 docs say since 1.6.. whom are we to believe?


No they don't. At the very bottom of the page for the 1.6 docs, it says "Since 1.6", but that's part of the description of the "reset()" method, which was added to Scanner in JDK 1.6. Much closer to the top of the page, in the description of the class itself, right after " Whitespace is not significant in the above regular expressions", it says "Since 1.5" on both pages.
 
Garrett Rowe
Ranch Hand
Posts: 1296
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Gamini Sirisena:
That since bit never registered for me to find in which version a Class was included.

But here's the bummer.. the JSE 5 docs say since 1.5 and JSE 6 docs say since 1.6.. whom are we to believe?


Huh?? They both say since 1.5. Where are you looking?
 
Joanne Neal
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Gamini Sirisena:
That since bit never registered for me to find in which version a Class was included.

But here's the bummer.. the JSE 5 docs say since 1.5 and JSE 6 docs say since 1.6.. whom are we to believe?


Actually both docs says the class is there since 1.5. There are some methods in the 1.6 docs that have only been there since 1.6
 
Gamini Sirisena
Ranch Hand
Posts: 378
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Right, got it.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic