简体   繁体   中英

What is the Eclipse equivalent of the NetBeans “Run As Main”?

What is the Eclipse equivalent of the NetBeans "Run As Main"?

I have a Java "main" class that contains the start code:

public static void main(String[] args)

Then I have another class foo that has a method bar .

When I am displaying (editing) the main class, and click the run icon, it runs normally. But when I am editing the foo class, and click the run icon, it says:

The selection did not contain any resources that may run on a server

NetBeans always knows to run the main class. Eclipse doesn't. Is there any way to teach Eclipse to play nicely?

Go to Run -> Run Configurations select your project and select Main class and click on Apply button and Run button

This will always run from your selected main class

Open the Preferences and in " Run/Debug " > " Launching " choose " Always launch the previously launched Application " (below " Launch Operation ").

Then, right-click on your Main class and choose " Run-As " > " Java Application ". Now when you edit your other classes and you click the run-button, Main will be launched again.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM