Pkarls
Pkarls

Reputation: 33

Is it possible to set which file to run by default in eclipse?

I'm writing a python project in Eclipse with the PyDev plug-in, which contains multiple files.

However I'm used to using visual studio, where it'll automatically find the main function of a project and run the program from there.

Eclipse will always run the file I am currently editing (which usually is a file containing function that are called from the main function).

Is it possible to set which file should be run then clicking run? I've looked at the launch options under Project->Properties->PyDev, but didn't find what I was looking for.

Upvotes: 3

Views: 1684

Answers (2)

Jonah Graham
Jonah Graham

Reputation: 7965

When you press the Debug or Run button enter image description here(Debug on the left) Eclipse tries to intelligently determine what to launch based on your current editor.

You can change the behaviour by editing Window -> Preferences -> Run/Debug -> Launching -> Launch Operation as pictured below.

The default of launching the current editor works well for some languages, but not as well for Python when every single file is itself a valid program to run. In your case I recommend changing to Always launch the previously launched application.

enter image description here

Upvotes: 2

bumble012
bumble012

Reputation: 81

You can create a custom run configuration. Right click on your project > run as > run configurations

From here is just a matter of choosing your project type on the left hand side and filling in the required information. You can click 'Run' to use your new configuration.

To get to this configuration again, you can click the 'Run' drop down button in the eclipse tool bar and see all of your run configurations.

Hope this helps!

Upvotes: 1

Related Questions