如何找出我的 Java Eclipse 项目有什么错误?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2484748/
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-08-13 08:16:55  来源:igfitidea点击:

How to figure out what error my Java Eclipse project has?

javaeclipse

提问by Greg Mattes

I've created a Java project from existing source with an Ant build script in Eclipse. I cannot run my project because Eclipse tells me that there is at least one error in it.

我已经在 Eclipse 中使用 Ant 构建脚本从现有源创建了一个 Java 项目。我无法运行我的项目,因为 Eclipse 告诉我其中至少有一个错误。

Now, I know that the project runs fine on the command line, so I suspect an Eclipse configuration error.

现在,我知道该项目在命令行上运行良好,所以我怀疑 Eclipse 配置错误。

As far as I can tell, the only feedback that I have from Eclipse is

据我所知,我从 Eclipse 得到的唯一反馈是

  1. a little red X on my project in the Package Explorer window Eclipse Error Package Explorer
    (source: gregmattes.com)

  2. and dialog window when I try to run the project says there are errors in the project Eclipse Error Dialog
    (source: gregmattes.com)

  1. 包资源管理器窗口中我的项目上的一个小红色 X (来源:gregmattes.comEclipse 错误包资源管理器

  2. 当我尝试运行项目时,对话框窗口说项目中有错误 (来源:gregmattes.comEclipse 错误对话框

This is all wonderful, but what is the error?

这一切都很棒,但错误是什么?

Is there a "show me the next error" button somewhere?

某处是否有“显示下一个错误”按钮?

In the past, on other Eclipse projects, I've notice other little red X's on folders containing source files with errors, the little red X's appear on the source files as well. I scanned (manually) through all of the source files and I haven't found any other red X's (again, where is the "next error" button?).

过去,在其他 Eclipse 项目中,我注意到包含错误源文件的文件夹上的其他小红 X,源文件上也出现小红 X。我(手动)扫描了所有源文件,但没有找到任何其他红色 X(同样,“下一个错误”按钮在哪里?)。

If I select the "Proceed" button I am greeted with a java.lang.NoClassDefFoundErrorfor my main class, which makes me suspect a classpath issue. I've checked the classpath, and I'm fairly certain that it's correct. Is there a way to see the exactjvm command line that Eclipse is invoking? I realize that it might be invoking the JVM programmatically, and not on a "real" command line. In any case, is there a way, other than the run configuration dialog, to see what is actually happeningwhen I hit the "Proceed" button?

如果我选择“继续”按钮java.lang.NoClassDefFoundError,我的主类会收到一个,这让我怀疑是类路径问题。我检查了类路径,我很确定它是正确的。有没有办法查看Eclipse 正在调用的确切jvm 命令行?我意识到它可能以编程方式调用 JVM,而不是在“真正的”命令行上。无论如何,除了运行配置对话框之外,还有什么方法可以查看当我点击“继续”按钮时实际发生的情况

采纳答案by Bozho

The errors are shown in the Problemsview. If it is not opened, go to:

错误显示在Problems视图中。如果未打开,请转到:

Window > Show View > Problems

Window > Show View > Problems

alt text

替代文字

Also accessible with the keyboard shortcut Alt+Shift+Q,X

也可通过键盘快捷键访问 Alt+Shift+Q,X

回答by Michael Borgwardt

Selecing Window -> Show View -> Problemswill open the Problems view, that should have a list of all problems, their location and nature (it can be configured to show only project- or file-local problems, so you may also have to click on the project). Most likely you have a config error in your project, e.g. a reference to a JAR library that cannot be found.

选择Window -> Show View -> Problems将打开问题视图,该视图应该包含所有问题、它们的位置和性质的列表(它可以配置为仅显示项目或文件本地问题,因此您可能还必须单击项目)。很可能您的项目中存在配置错误,例如无法找到对 JAR 库的引用。

回答by Karan Thakkar

if you get that kind of an error which shows a red cross on the project folder just refresh that project right clicking on it i was having the same problem as above so try and see...

如果您遇到那种在项目文件夹上显示红色叉号的错误,只需右键单击该项目即可刷新该项目,我遇到了与上述相同的问题,因此请尝试查看...