0

I've been using Eclipse on a few computers recently, and since using it on my home computer, have found that it doesn't automatically import java.util.* or java.util.Scanner after declaring a Scanner class in my code.

In my code, I type something like:

Scanner sc = new Scanner(System.in);

... and in the past, Eclipse would add the import java.util.Scanner or import java.util.* line above my class.

Any idea how I could get the program to do this for me? I know it's a very insignificant thing, but everything I learn about Eclipse or programming makes me a stronger programmer.

Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
zsatei
  • 11
  • 1
  • 1
  • 2
  • 5
    Does `Ctrl+Shift+O` help you? – Rohit Jain Apr 03 '15 at 09:16
  • Not sure but maybe this could help? http://stackoverflow.com/questions/6293475/organize-imports-automatically – ceekay Apr 03 '15 at 09:20
  • Thanks for the suggestion guys - good alternative, but not quite the same as what my other computers were doing. – zsatei Apr 03 '15 at 10:44
  • Related, possible duplicate [Can eclipse be configured to automatically fix missing Imports?](https://stackoverflow.com/questions/3982885/can-eclipse-be-configured-to-automatically-fix-missing-imports) – Mark Rotteveel Apr 02 '22 at 16:10

1 Answers1

1

Use the shortcut ctrl+shft+o in Eclipse. It automatically imports whatever classes needed and suggests you with possible imports if conflict occurs.

Vanaja Jayaraman
  • 753
  • 3
  • 18
  • This is great help, thank you! The problem, however, is that the other computers I was working on (with the same Eclipse version) did it automatically, no CTRL+SHIFT+O necessary. This seemed pretty friendly and, as it required no input whatsoever, was easy. Any idea if this is a setting somewhere? – zsatei Apr 03 '15 at 10:41