Eclipse 运行之前的程序

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

Eclipse running previous program

eclipse

提问by jxhyc

It is a new problem. I copy paste a program and try to run it in eclipse. But the eclipse keeps running an older program. I have no idea what is going on. ( I saved the program as someone on the internet suggested) In the run button, there are only old programs. So I goes into the run configuration option and double clicked the java application option and somehow the one I am working on right now appeared. And I am able to compile and run the current one. So technically I solved the problem, but I would like an explanation, what was going on?

这是一个新问题。我复制粘贴一个程序并尝试在 Eclipse 中运行它。但是日食一直在运行旧程序。我不知道发生了什么。(我按照网上某人的建议保存了程序)在运行按钮中,只有旧程序。因此,我进入运行配置选项并双击 java 应用程序选项,不知何故,我现在正在处理的选项出现了。我能够编译和运行当前的。所以从技术上讲我解决了这个问题,但我想解释一下,这是怎么回事?

enter image description here

在此处输入图片说明

回答by Jonah Graham

What is going on here is how Eclipse decides what to Run when you press the Runbutton. My suspicion is you have settings which are causing it to launch the last launched item, rather than something new that does not have a launch configuration. If you hover over the Runicon, it will show the name of the launch configuration that Eclipse will launch.

这里发生的事情是当您按下Run按钮时 Eclipse 如何决定要运行的内容。我怀疑您的设置导致它启动最后一个启动的项目,而不是没有启动配置的新项目。如果将鼠标悬停在该Run图标上,它将显示 Eclipse 将启动的启动配置的名称。

For a new program, you want to do a Run As-> Java Application(From Runmenu).

对于新程序,您需要执行Run As-> Java Application(从Run菜单)。

To configure the default launching behaviour, see Preferences-> Run/Debug-> Launching, and then set the options you want in the Launch Operationgroup.

要配置默认启动行为,请参阅Preferences-> Run/Debug-> Launching,然后在Launch Operation组中设置所需的选项。

launching preference page

启动偏好页面

回答by Kms

@Jonah Graham, answer is perfect but could not working in my case. because I'm unable to see Java Applicationoption from Run menu.

@Jonah Graham,答案很完美,但在我的情况下不起作用。因为我无法从运行菜单中看到Java 应用程序选项。

enter image description here

在此处输入图片说明

I have around 40+ classes in my project and when I'm trying to run some classes for which java application option is not visible, the class is getting executed which is selected in RunButton in eclipse.

我的项目中有大约 40 多个类,当我尝试运行一些 Java 应用程序选项不可见的类时,该类正在执行,该类在 Eclipse 的运行按钮中被选中。

Hover over to Run button and observe the class name which is getting executed.

将鼠标悬停在运行按钮上并观察正在执行的类名。

enter image description here

在此处输入图片说明

Solution:

解决方案:

Delete all previous configurations by going to the Run Configurationswindow and then add a new configuration where you add your file.

通过转到“运行配置”窗口删除所有以前的配置,然后在添加文件的位置添加新配置。

回答by Andrew Lyubovsky

Exit out of eclipse, then open Eclipse in a new Workspace and create a new Project. This is a quick solution if you are willing to have multiple workspaces.

退出 eclipse,然后在新的 Workspace 中打开 Eclipse 并创建一个新的 Project。如果您愿意拥有多个工作区,这是一个快速的解决方案。