简体   繁体   English

如何使Eclipse用红色下划线表示不存在的导入?

[英]How can I get Eclipse to underline in red the imports which don't exist?

I recently switched IDE's to Eclipse. 我最近将IDE切换到Eclipse。 Just to test that I am not insane, I added something like 为了测试我不是疯了,我添加了类似

import x;

to the top of the Java file. 到Java文件的顶部。 I was expecting to see the red squiggly line underlining the library the IDE can't find, but it didn't do it automatically. 我期望看到红色的波浪线突出显示了IDE找不到的库,但这不是自动执行的。

How can I set the Eclipse setting to tell me if some syntax is wrong, or a library I am importing isn't in place? 如何设置Eclipse设置以告诉我某些语法是否错误,或者我要导入的库不在位?

It should flag it as a compiler error automatically (including the squiggly line). 它应该自动将其标记为编译器错误(包括弯曲的行)。 You might need to convince it to rebuild the project. 您可能需要说服它来重建项目。 Are you automatically building the project, or doing it manually? 您是自动构建项目还是手动进行? Eclipse occasionally loses track of automatic rebuilds. Eclipse偶尔会丢失自动重建的轨道。

Unresolvable imports are a compiler error, not something you configure in Eclipse. 无法解决的导入是编译器错误,而不是您在Eclipse中配置的错误。

Make sure the file is located under a Java source directory: 确保文件位于Java源目录下:

Project > Properties > Java Build Path > Source tab

Also verify that Project > Build Automatically is enabled. 还要确认已启用“ Project > Build Automatically You may need to do a Project > Clean to jump start automatic builds. 您可能需要执行“ Project > Clean才能开始自动构建。

I can change mine in the following preferences. 我可以在以下首选项中更改我的。

Window->Preferences
General->Editors->Text Editors->Annotations
Annotation types->Errors

Check the box: Text as
Select: Native Problem Underline as the drop down
Choose a color

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何让我在 eclipse 中的导入工作? - How can I get my imports in eclipse to work? 如何使程序帐户中的数组列表中不存在的索引 - How do I make the program account for indexes which don't exist in the array-list Eclipse中粗体黑色光标删除代码,我不知道如何摆脱它 - Bold black cursor in Eclipse deletes code, and I don't know how to get rid of it ImageJ,Java:如何将红色像素所包围的像素设置为红色(避免出现孔) - ImageJ, Java: How can I set Pixels red which are sourounded by red Pixels (avoid holes) 如何从列表A中获取列表B中不存在的元素 - How to get elements from List A that don't exist in List B Eclipse Neon可以确定我不需要开发的项目吗? - Can Eclipse Neon determinate the projects I don't need for developement? 如何获得我不知道的数组的索引? - How do I get the index of an array which I don't know? 我得到一个我不知道的例外 - I get an exception which I don't know MapStruct:如何过滤到我想要和不想映射的字段? - MapStruct: How can I do filter to fields which I want and don't want to mapping? 如何告诉jackson忽略我无法控制源代码的属性? - How can I tell jackson to ignore a property for which I don't have control over the source code?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM