eclipse 如何运行不同的类

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

eclipse how to run a different class

javaeclipseclass

提问by Nicholas Kong

I want to work on my different class lets say for example house.java but the green play button seems to be locked a program called project.java and only that program. how do I tell Eclipse to run a different classes in the same folder besides the project.java?

我想在我的不同班级上工作,例如 house.java 但绿色播放按钮似乎被锁定了一个名为 project.java 的程序,并且只有那个程序。除了 project.java 之外,我如何告诉 Eclipse 在同一文件夹中运行不同的类?

回答by Gryphius

select your class, then select the small triangle right to the green button, in the dropdown select "Run As" -> "Java Application"

选择您的课程,然后选择绿色按钮右侧的小三角形,在下拉列表中选择“运行方式”->“Java 应用程序”

回答by HashimR

Apart from ways mentioned in the other answers, you can also try this short key.

除了其他答案中提到的方法外,您还可以尝试使用此快捷键。

Short key : Press ALT + SHIFT + X then J

快捷键:按 ALT + SHIFT + X 然后按 J

Hope this helps. :)

希望这可以帮助。:)

回答by Android Killer

You can directly left click on your corresponding class code which you want to run and go to run as-->java application.hope this will help. :)

您可以直接左键单击要运行的相应类代码,然后转到run as-->java application 。希望这会有所帮助。:)

回答by Muhammad Imran Tariq

First thing to note that class you want to run should have main method in it. right click on that class and run as --> java application. it will run :)

首先要注意的是,您要运行的类中应该有 main 方法。右键单击该类并作为 --> java 应用程序运行。它会运行:)

回答by Shravan Reddy

mainmethod is missing in your script:

main您的脚本中缺少方法:

public static void main(String[] args)