简体   繁体   中英

running java programs in Eclipse

I am having a problem running java programs in Eclipse,

When i Click on Run button to Run the Project i get error until i manually Add that project in Run Configurations , Why do i have to add Evey project in Run configurations before running it ? If i have a single .java file i couldn't be able to run this file as i cannot add this File in Run Configurations because it is just a single file not a complete project having a package.

Last time when i was using eclipse and whenever i click on Run the project i selected automatically runs without adding it inside the Run configurations but since i Deleted and Eclipse and Re-Install it i am facing these kind of troubles , could somebody help me out ?

右键单击您的主类>运行方式...> Java应用程序

Right-click on the java class you want to run and select Run as > Java application

Your class must have a method with this signature:

public static void main(String[] args) 

There's a configuration for what the run button does. it will either try to relaunch whatever was launched previously, or will try to launch the currently open document, which could be an xml file too... look into window->preferences and search for "run" or "launch"

If its a single java file then you can right click on the file and select the "run as java application" option to allow you to run the program.

The Run Configurations option is used to make sure that you save some project specific run setings and use that shortcut each time to run the project.

For single programs i think the first option is better.

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