ECLIPSE:错误:在类apple中找不到主要方法,请将该主要方法定义为:public static void main(String [] args) [英] ECLIPSE : Error: Main method not found in class apple, please define the main method as: public static void main(String[] args)

查看:48
本文介绍了ECLIPSE:错误:在类apple中找不到主要方法,请将该主要方法定义为:public static void main(String [] args)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Java的初学者.这段代码在命令提示符下运行正常,但是在eclipse中它没有运行!

I am beginner to java. This code is working absolutely fine in command prompt but here in eclipse it is not running !

class apple{
    public static void main (String[] args){
       System.out.println("Hello , World") ;
    }
} 

推荐答案

您需要选择要运行的Java应用程序:右键单击项目的根目录,运行方式>运行配置.

You need to select your Java Application to be run: Right-click on your project root directory, Run As > Run Configurations.

在左侧选择Java应用程序,如果"Java应用程序"下有一个Configuration,则选择它(如果未创建).然后在主要"选项卡下,选择搜索并在您的项目中找到主要类.

On the left-side select Java Application, if there is a Configuration under 'Java Application', then select it, if not create it. Then under the 'Main' tab, select search and find the Main class in your project.

然后选择运行.

失败的其他原因:

  • 在运行之前未保存项目.
  • Eclipse故障,请尝试重新启动.

这篇关于ECLIPSE:错误:在类apple中找不到主要方法,请将该主要方法定义为:public static void main(String [] args)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆