Sufiyan Ghori
Sufiyan Ghori

Reputation: 18763

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 ?

Upvotes: 0

Views: 214

Answers (4)

Som Bhattacharyya
Som Bhattacharyya

Reputation: 4112

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.

Upvotes: 1

Peter Perháč
Peter Perháč

Reputation: 20792

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"

Upvotes: 1

Bohemian
Bohemian

Reputation: 425428

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) 

Upvotes: 2

Marcelo
Marcelo

Reputation: 4608

Right click your main class > Run As... > Java Application

Upvotes: 2

Related Questions