Import package rather than class

I can do

directoryObject = DirectoryChooser("select directory");

But why can’t I (or how would I do the equivalent of)

directoryObject = io.DirectoryChooser("select directory");

If I’m going to use multiple methods in io, seems like it would be more efficient to do it the 2nd way, rather than having to import every class.

Is there a way?

Once again, found the answer:

imports ALL the classes in the package. It’s kind of a strange way to do it, but it works.

Note that doing blanket import of packages is not considered “best practice”—see e.g. this SO post for details. Personally, I would recommend importing each class separately. See also the JavaScript Scripting page if you haven’t already.

I can totally see that. It wastes memory and resources. That’s why using a qualified path would make sense (like you do in other languages).

It’s more about maintainability and potential for future breakages, actually. At least in Java, the imports are only used at compile time, so whether you use wildcards should not (by itself) affect the final bytecode.