| Author |
Accessing the java.util.Scanner Utility
|
Benjamin Chau
Ranch Hand
Joined: Oct 05, 2008
Posts: 49
|
|
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
Joined: Aug 05, 2005
Posts: 3011
|
|
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.
|
Joanne
|
 |
Varun Chopra
Ranch Hand
Joined: Jul 10, 2008
Posts: 204
|
|
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.
|
-Varun -
(My Blog) - Mock Tests
|
 |
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32712
|
|
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
Joined: Oct 05, 2008
Posts: 49
|
|
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
Joined: Aug 05, 2008
Posts: 347
|
|
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
Joined: Jul 08, 2003
Posts: 24061
|
|
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.
|
[Jess in Action][AskingGoodQuestions]
|
 |
Garrett Rowe
Ranch Hand
Joined: Jan 17, 2006
Posts: 1295
|
|
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?
|
Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them. - Laurence J. Peter
|
 |
Joanne Neal
Rancher
Joined: Aug 05, 2005
Posts: 3011
|
|
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
Joined: Aug 05, 2008
Posts: 347
|
|
|
Right, got it.
|
 |
 |
|
|
subject: Accessing the java.util.Scanner Utility
|
|
|