Is java.util automatically called in eclipse when you write your code ? where does it "get" the classes it imports?


This code doesn't work:

import java.util.Scanner;

public class InputTest {
    public static void main (String[] args)
        Scanner in = new Scanner(System.In);
        System.out.print("What is your name ?");
        String name = in.nextLine();

        System.out.print("How old are you?");
        int age = in.nextInt();

        System.out.println("Hello " + name + "You'll be");

Does it have to do with my java.util at the beginning not working correctly ? Error message: Exception in thread "main" java.lang.Error: Unresolved compilation problem: In cannot be resolved or is not a field

at InputTest.main(

Show source
| java   | eclipse   | java.util.scanner   2017-01-03 21:01 1 Answers

Answers ( 1 )

  1. 2017-01-03 21:01

    The problem has nothing to do with imports. The reference to the standard input in java is, with a lowercase i, not a capital one:

    Scanner in = new Scanner(;
    // Here ------------------------^
◀ Go back