Issue
I just installed Ubuntu 8.04 and Eclipse.
I made a very simple Hello World program in order to ensure that everything is running smoothly. When I attempted to use the Scanner class for acquiring some user input I got a very odd error.
My code:
import java.util.Scanner;
class Test {
public static void main (String [] args) {
Scanner sc = new Scanner(System.in);
System.out.println("hi");
}
}
Error message
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 test.main(test.java:5)
Solution
The Scanner class is new in Java 5. I do not know what Hardy's default Java environment is, but it is not Sun's and therefore may be outdated.
I recommend installing the package sun-java6-jdk to get the most up-to-date version, then telling Eclipse to use it.
Answered By - Thomas Answer Checked By - Timothy Miller (WPSolving Admin)