Eclipse 问题视图不显示错误

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2503082/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 19:16:30  来源:igfitidea点击:

Eclipse Problems View doesn't show Errors

eclipse

提问by volni

[Note: There is another thread about this problem but it did not answer the question.]

[注意:还有关于这个问题的另一个线程,但它没有回答这个问题。]

For one specific project in Eclipse, the problems view does not show errors. It shows warnings but it does not show errors. The other projects do show errors (and everything else). For that problematic project, I can see the red squiggly error line in the files. However, the directory structure does not show an error icon and the error is not populated in the Problems View.

对于 Eclipse 中的一个特定项目,问题视图不会显示错误。它显示警告,但不显示错误。其他项目确实显示错误(以及其他所有内容)。对于那个有问题的项目,我可以在文件中看到红色波浪形错误行。但是,目录结构不显示错误图标并且错误未填充在问题视图中。

Any ideas?

有任何想法吗?

采纳答案by volni

For anyone else who is having this problem, I have found the answer:

对于遇到此问题的其他人,我找到了答案:

Make sure that Eclipse recognizes your project as a Java project. Specifically, under Project Properties ensure that you have a Java Builder that is checked.

确保 Eclipse 将您的项目识别为 Java 项目。具体来说,在 Project Properties 下确保您有一个已检查的 Java Builder。

That way, your project will be built and you will see errors in the Problems view.

这样,您的项目将被构建,您将在问题视图中看到错误。

回答by Alexander Pogrebnyak

I want to post my story here if Google brings you to this question.

如果谷歌给你带来这个问题,我想在这里发布我的故事。

Somehow, "Project->Build Automatically" got turned off.

不知何故,“项目->自动构建”被关闭了。

enter image description here

在此处输入图片说明

Turning it back on produces correct errors list.

重新打开它会产生正确的错误列表。

I've tested that this is the case as far as Ganymede ( at the point of writing this post I am running Indigo )

我已经测试过就 Ganymede 而言就是这种情况(在撰写本文时,我正在运行 Indigo)

回答by Neal Swearer

You'll likely need to change the filter on the Problems view to see the errors. There's a downward pointing arrow in the upper right corner of the panel. Click it -> Configure Contents..., and in the Scope make sure "On any element" is selected.

您可能需要更改问题视图上的过滤器才能查看错误。面板右上角有一个向下的箭头。单击它 -> 配置内容...,并在范围中确保选择了“在任何元素上”。

回答by lini sax

I had the problem where in the red cross icon by the file name did not appear. I tried all possibilities described on this question. However, the root cause in my case was, I deleted a jar file from SVN. So the java file using the imports from this jar had errors. Surprisingly that didn't show up.

我遇到了文件名旁边的红十字图标没有出现的问题。我尝试了在这个问题上描述的所有可能性。但是,在我的案例中,根本原因是,我从 SVN 中删除了一个 jar 文件。所以使用从这个 jar 导入的 java 文件有错误。令人惊讶的是,这并没有出现。

Looking at the build path, I found under Java Build Path -> Libraries -> jar (missing). Having removed it from the build path, the red icon next to the file showed up !! Excruciating it was to find this error and wasting so much time, I wonder why this icon does not show up nor does Problem view report it.

查看构建路径,我在Java Build Path -> Libraries -> jar (missing) 下找到了。从构建路径中删除它后,文件旁边的红色图标出现了!!痛苦的是发现这个错误并浪费了这么多时间,我想知道为什么这个图标不显示,问题视图也没有报告它。

回答by Tomá? Zálusky

I googled this question having same problem, my solution was simply Project -> Clean.

我在 google 上搜索了这个有同样问题的问题,我的解决方案只是 Project -> Clean。

回答by Sanket Mehta

I checked the .classpath file of the Eclipse project. It had incorrect value of src so it was pointing to the wrong source of Java files.

我检查了 Eclipse 项目的 .classpath 文件。它的 src 值不正确,因此它指向了错误的 Java 文件源。

My files incorrect entry:

我的文件不正确的条目:

<classpathentry kind="src" path="src"/>

I changed it to the correct entry:

我将其更改为正确的条目:

<classpathentry kind="src" path="source/java"/>

Now it is working.

现在它正在工作。

回答by user1861650

My problem was that I had a project that I had not edited in a while, so it was linking on a version of the jre that I no longer had on my system. I went to the project properties --> java build path and deleted the reference to the outdated jre.

我的问题是我有一个我有一段时间没有编辑过的项目,所以它链接到我的系统上不再有的 jre 版本。我去了项目属性--> java构建路径并删除了对过时jre的引用。

回答by egilchri

I am a newbie to STS, and I had a similar problem. Errors weren't showing up until I saved the file. I discovered it was because I was using the Text Editor, instead of the Java Editor.

我是 STS 的新手,我遇到了类似的问题。直到我保存文件,错误才出现。我发现这是因为我使用的是文本编辑器,而不是 Java 编辑器。

回答by ecle

Here is the solution I use when the red icons do not appear on the project tree to highlight errors in our project files from Eclipse (Windows version).

这是我在项目树上没有出现红色图标以突出显示来自 Eclipse(Windows 版本)的项目文件中的错误时使用的解决方案。

Make sure Eclipse is running on the correct JVM. By default, it will use the latest JRE classpath stored in a registry. If you need to run Eclipse from a JDK instead of JRE, you need to tell Eclipse. So, add the -vm option at the top of the eclipse.inito refer to our preferred JDK as follows:

确保 Eclipse 在正确的 JVM 上运行。默认情况下,它将使用存储在注册表中的最新 JRE 类路径。如果您需要从 JDK 而不是 JRE 运行 Eclipse,您需要告诉 Eclipse。因此,在顶部添加 -vm 选项eclipse.ini以引用我们首选的 JDK,如下所示:

-vm 
C:\Program Files\Java\jdk1.7.0_21/bin/javaw.exe

Remember to change this when you are upgrading your JRE/JDK.

请记住在升级 JRE/JDK 时更改此设置。

However, we may encounter issue with Mavencomplaining about tools.jarin a project's pom.xml. If Eclipse is running on Java JRE instead of JDK, it can be a problem to some Maven plugins like maven-bundle-pluginthat still rely on tools.jarwhich only exists on JDK, causing it to complain. Don't worry about it if your still prefer to run Eclipse using JRE as you can put this entry inside your project's pom.xmlto explicitly refer to the right tools.jar:

但是,我们可能会遇到的问题Maven的抱怨tools.jar在项目的pom.xml。如果 Eclipse 运行在 Java JRE 而不是 JDK 上,那么对于一些 Maven 插件(如maven-bundle-plugin仍然依赖于tools.jar仅存在于 JDK上的插件)来说,这可能是一个问题,导致它抱怨。如果您仍然喜欢使用 JRE 运行 Eclipse,请不要担心,因为您可以将此条目放入您的项目中pom.xml以明确引用正确的tools.jar

<profiles>
    <profile>
        <id>default-profile</id>
        <activation>
            <activeByDefault>true</activeByDefault>
            <file>
                <exists>${java.home}/../lib/tools.jar</exists>
            </file>
        </activation>
        <properties>
            <toolsjar>${java.home}/../lib/tools.jar</toolsjar>
        </properties>
    </profile>
    <profile>
        <id>windows_profile</id>
        <activation>
            <os>
                <family>Windows</family>
            </os>
        </activation>
        <properties>
            <toolsjar>${java.home}/../lib/tools.jar</toolsjar>
        </properties>
    </profile>
    <profile>
        <id>osx_profile</id>
        <activation>
            <os>
                <family>mac</family>
            </os>
        </activation>
        <properties>
            <toolsjar>${java.home}/../Classes/classes.jar</toolsjar>
        </properties>
    </profile>
</profiles>