为什么Eclipse无法识别Java库? [英] Why is Eclipse not recognizing Java libraries?

查看:395
本文介绍了为什么Eclipse无法识别Java库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能我误解了这个问题,所以我可能会问错问题.我正在使用Mac OSX 10.8.3,并且正在eclipse中创建一个applet.当我尝试使用import java.*时,其中*awtappletutil

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显示错误,基本上表现为似乎无法识别Java库.在首选项中,我选择了Java SE 6 JRE.我尝试将编译器的遵从性级别降低到1.6,但似乎没有任何作用.

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.

对于我导入的某些类,代码是在Windows机器上编写的,但我认为那没有什么关系.有什么想法吗?

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?

推荐答案

删除导入,然后Eclipse应该检测到您所需的导入没有导入.然后按 CTRL + SHIFT + O 来组织导入,Eclipse将自动检索您需要的每个导入.

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.

此外,您绝不应该进口过多的商品.如果import java.*甚至可以工作(这永远都做不到),那将是一个可怕的做法,因为所有这些库都必须加载到内存中(甚至不需要的那些库).为了节省内存空间,请避免在导入中使用*(在组织导入时Eclipse会这样做).

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).

这篇关于为什么Eclipse无法识别Java库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆