Reputation: 23
Possibly I am misunderstanding the problem, so I may be asking the wrong question. I am using Mac OSX 10.8.3 and I am creating an applet in eclipse. When I try using import java.*
where *
is awt
, applet
, util
, etc.
Eclipse shows errors, basically behaving as if it does not recognize the Java libraries. In the preferences I have the Java SE 6 JRE selected. I tried lowering the compiler compliance level to 1.6 but it didn't seem to do anything.
For some of the classes I imported the code was written on a windows machine, but I don't see how that would matter. Any thoughts?
Upvotes: 1
Views: 1974
Reputation: 8247
Remove the imports, and then Eclipse should detect that the imports you need are not imported. Then press CTRL+SHIFT+O to organize your imports, and Eclipse should automatically retrieve every import you need.
Also, you should never import more than you have to. If import java.*
even worked (which it never will), it would be a horrible practice, because then all those libraries have to be loaded into memory (even the ones you don't need). To conserve memory space, avoid using *
with imports (Eclipse does this when you organize the imports).
Upvotes: 1
Reputation: 10851
If you import java.*
you only import all classes, interfaces, and so on, which are in the java
folder. To import classes out of utils you will have to import java.utils.*
. The *
is does not work recursively. It's better practise to just import classes that you really need. Normally Eclipse suggested automated import statement generations.
Upvotes: 0