Eclipse Java 错误:无法启动此选择并且最近没有启动

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

Eclipse Java error: This selection cannot be launched and there are no recent launches

javaeclipse

提问by Joseph Marr

I have looked everywhere on the internet and tried everything the forums say to do and nothing works. This error keeps coming up. I have tried running my java project (not for android) even the drop down run as button doesn't work because it says "none applicable".

我在互联网上到处寻找并尝试了论坛所说的一切,但没有任何效果。这个错误不断出现。我试过运行我的 java 项目(不适用于 android),即使下拉运行按钮不起作用,因为它说“不适用”。

回答by MarsAtomic

Eclipse needs to see a main method in one of your project's source files in order to determine what kind of project it is so that it can offer the proper run options:

Eclipse 需要在您的项目源文件之一中查看 main 方法,以确定它是哪种项目,以便它可以提供正确的运行选项:

public static void main(String[] args)

Without that method signature (or with a malformed version of that method signature), the Run As menu item will not present any run options.

如果没有该方法签名(或该方法签名的格式错误),“运行方式”菜单项将不会显示任何运行选项。

回答by Neeraj Attri

Click on the drop down next to the Run button, After that choose Run Configuration, shows three option, for example i choose java application add class(Name of the class of your project) in that then Click on the ok button ...Run your application :)

单击“运行”按钮旁边的下拉菜单,然后选择“运行配置”,显示三个选项,例如我选择 java 应用程序添加类(项目类的名称),然后单击“确定”按钮...运行你的申请 :)

Neeraj

尼拉吉

回答by FRANK

Make sure the "m" in main() is lowercase this would also cause java not to see your main method, I've done that several times unfortunately.

确保 main() 中的“m”是小写的,这也会导致 java 看不到你的 main 方法,不幸的是我已经这样做了几次。

回答by Piyush Gupta

Check, you might have written this statement wrong.

检查,您可能写错了此语句。

public static void main(String Args[])

I have also just started java and was facing the same error and it was occuring as i didn't put []after args. so check ur statment.

我也刚开始使用 java 并面临同样的错误,这是因为我没有放在[]args 之后。所以检查你的声明。

回答by Nish

It happens when sometimes we copy or import the project from somewhere. The source folder is a big thing to concern about.

有时我们从某个地方复制或导入项目时会发生这种情况。源文件夹是一个值得关注的大事。

One simple technique is, create a new project, inside the source folder, create a new class and paste the content over there.

一种简单的技术是,在源文件夹中创建一个新项目,创建一个新类并将内容粘贴到那里。

It will work...

它会工作...

Hope it helps.

希望能帮助到你。

回答by Emre Turan

When you create a new class file, try to mark the check box near

创建新的类文件时,尝试将复选框标记为

public static void main(String[] args) {

this will help you to fix the problem.

这将帮助您解决问题。

回答by Vishal Patil

click on the project that you want to run on the left side in package explorer and then click the Run button.

在包资源管理器的左侧单击要运行的项目,然后单击“运行”按钮。

回答by XciA

Check if the filename is same as the classname used by your program.

检查文件名是否与程序使用的类名相同。

eg.:

例如。:

class Dfs{ psvm(String[] args){}}

filename should be Dfs.java

文件名应该是 Dfs.java

回答by XciA

Have you checked if:

您是否检查过:

  1. You created a classfile under srcfolder in your JAVA project?(not file)
  2. Did you name your class as the same name of your class file?
  1. 您在 JAVA 项目中的class文件src夹下创建了一个文件?(不是file
  2. 您是否将您的班级命名为与您的班级文件相同的名称?

I am a newbie who try to run a helloworld example and just got the same error as yours, and these work for me.

我是一个尝试运行 helloworld 示例的新手,但遇到了与您相同的错误,这些对我有用。