I know, It's quite a while since the question was posted. But the solution may still be of interest to anyone out there. It's actually quite simple...
Under Ubuntu you need to set the java compiler "javac" to use sun's jdk instead of any other alternative. The difference to some of the answers posted so far is that I am talking about javac NOT java. To do so fire up a shell and do the following:
- As root or sudo type in at command line:
# update-alternatives --config javac
Locate the number pointing to sun's jdk, type in this number, and hit "ENTER".
You're done! From now on you can enjoy java.util.Scanner under Ubuntu.
System.out.println("Say thank you, Mr.");
Scanner scanner = java.util.Scanner(System.in);
String thanks = scanner.next();
System.out.println("Your welcome.");