Java Eclipse 甚至不会在被告知时尝试编译/运行
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18800513/
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
Eclipse won't even try to compile/run when told to
提问by ToxicTeacakes
When I click the run button, nothing happens. Eclipse Kepler doesn't tell me that there are any errors in my code, but it does tell me that my program is running. There are no errors output, no log files appear, nothing.
当我单击运行按钮时,没有任何反应。Eclipse Kepler 没有告诉我我的代码中有任何错误,但它确实告诉我我的程序正在运行。没有错误输出,没有日志文件出现,什么都没有。
Even the below doesn't work:
即使下面不起作用:
public class Main {
public Main() {
// TODO Auto-generated constructor stub
}
public static void main(String[] args) {
// TODO Auto-generated method stub
System.out.println("frog");
}
}
On latest stable release of arch linux, using a version of eclipse installed through the official repos.
在 arch linux 的最新稳定版本上,使用通过官方存储库安装的 eclipse 版本。
EDIT I opened a new, fresh project and everything runs fine. It appears (surprise surprise) the problem is the rest of the code in the project file, not Eclipse. However, even after several restarts of my computer my real project won't run.
编辑我打开了一个新的项目,一切正常。看起来(惊喜)问题是项目文件中的其余代码,而不是 Eclipse。但是,即使在我的计算机重新启动几次之后,我的真实项目也不会运行。
I suppose the only thing to do is remove the source files one by one and see if any of them are the problem.
我想唯一要做的就是一个一个地删除源文件,看看其中是否有问题。
采纳答案by ToxicTeacakes
If anyone else has this problem, I resolved it by doing the following:
如果其他人有这个问题,我通过执行以下操作来解决它:
- Re-installing Eclipse
- Creating a new project
- Making new class files and copying the information across from the old class files individually.
- 重新安装 Eclipse
- 创建一个新项目
- 制作新的类文件并分别从旧的类文件中复制信息。
Evidently, it was a problem with that particular working directory/project.
显然,这是该特定工作目录/项目的问题。
回答by Martin Seeler
Without more informations, there might be some solutions:
没有更多信息,可能有一些解决方案:
try to compile and run it by hand and see, if it's an eclipse related bug
Maybe you have selected the wrong console in your view? Try to switch through them
Maybe an previous program did not terminate and you still see this console
Maybe you have a strange colorscheme and you textcolor is the same as background?^^
尝试手动编译并运行它,看看它是否是与 Eclipse 相关的错误
也许您在视图中选择了错误的控制台?尝试切换它们
也许以前的程序没有终止,你仍然看到这个控制台
也许你有一个奇怪的配色方案,而你的 textcolor 与背景相同?^^
回答by Kerneels Roos
I had the same problem: everything worked just fine, close, restart Windows, run Eclipse (which loaded the last workspace with the last project open), but although there are no "errors" in the Problem window, nothing runs when I do Alt+Shift+X, J (shortcut for Run Java Program).
我遇到了同样的问题:一切正常,关闭,重新启动 Windows,运行 Eclipse(在最后一个项目打开的情况下加载了最后一个工作区),但是尽管“问题”窗口中没有“错误”,但是当我执行 Alt 时没有任何运行+Shift+X, J(运行 Java 程序的快捷方式)。
Introducing a syntax error in the code correctly reports the error, as well as the error going away when the syntax error is fixed. Cleaning the solution had no effect.
在代码中引入语法错误会正确报告错误,以及修复语法错误后错误消失。清洗溶液没有效果。
Dropping to the command line, Maven still compiles everything perfectly. Inspecting the Eclipse Error Log window I did find many warnings, but no errors. Finally I tried per chance the Run > Run Ctrl+F11 menu option, and then it ran the program just fine as expected. After that the console displayed output as before, and now the Alt+Shift+X, J shortcut, as well as the Alt+Shift+X, T shortcut (for running JUnit tests) started to work as before!
放到命令行中,Maven 仍然可以完美地编译所有内容。检查 Eclipse 错误日志窗口,我确实发现了许多警告,但没有发现错误。最后,我尝试了 Run > Run Ctrl+F11 菜单选项,然后它按预期运行了程序。之后控制台像以前一样显示输出,现在 Alt+Shift+X, J 快捷方式以及 Alt+Shift+X, T 快捷方式(用于运行 JUnit 测试)开始像以前一样工作!
Now, after running a program or a test, jumping to the console with Alt+Shift+Q, C works fine again. I can only conclude that for some reason, the console was not initialized, but in addition to that, the code really did not run since file output that the program generates also did not happen.
现在,在运行程序或测试后,使用 Alt+Shift+Q 跳转到控制台,C 再次正常工作。我只能得出结论,由于某种原因,控制台没有初始化,但除此之外,代码确实没有运行,因为程序生成的文件输出也没有发生。