• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Accessing the java.util.Scanner Utility

 
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 213
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Marshal
Posts: 79239
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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>
 
Ranch Hand
Posts: 378
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 1296
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Right, got it.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic