The import command "pulls from the package" named in the statement.
Take for example the Math class. Officially named java.lang.Math
This tells you the class named Math is in the package named lang which happens to reside in a higher package of the hierarchy named java. The compiler must know where to find the java package to get the ball rolling, this is set up differently based on the development environment.
Drop that class into a folder with the package name and it will be fine, or even create your own new package name, or when you have none at all, it is considered to be in the default package, which is why it works without the statement.