Is it possible to set which file to run by default in eclipse? - 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.

When you press the Debug or Run button (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.

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!

Related

Clicking run configurations not working for the java file I click on is my eclipse bugged or is this a simple fix?

Every time I right click on a java file to use the run configuration it won't open for that specific file I'm clicking on but the one I previously did. It will do the same for the button on the menu bar at top. I also noticed that it will only allow me to right click and use run configuration on the one I want only until after I run the program and get a run time error. I've tried to restart eclipse but it does the same thing still. So is this a bug on eclipses part or is it a preference option that can be changed?
Currently using Eclipse IDE for Java Developers - 2021-06
This all depends on what object you are right-clicking on, and its characteristics. If Eclipse doesn't see a "main" method, it won't allow running it as a Java Application.
In any case, you've provided very little information here. For instance, we have no idea what "it won't open" means.

Make Eclipse debug a default project instead of current

I'm currently working with a multi-platform project, where you have a main common library and several different platform setups (-android, -windows, -mac).
When I click debug while editing a library class, Eclipse asks me for a main class to launch, when it really cannot execute anything. I would like to change the behavior so when I start debugging while in a library class, any of the other projects will be the one launched by default.
As far as I have seen, Eclipse allows multilaunch, command parameters and favorites, but never default to other projects.
Not sure if this is exactly what you want, but you can set Eclipse to always launch the previous launch by default. Go to Preferences -> Run/Debug -> Launching and select "Always launch the previous application".

How do you configure Eclipse to automatically "run as Scala application"?

I made a Scala package and a Scala application in Eclipse, but every time I try to run it from Run > Run, Eclipse asks me:
Select a way to run 'example.scala':
- Java Application
- Scala Application
How can I get Eclipse to know that the project or application file should always run as Scala?
Click on the menu item named Window in your Eclipse window.
Select Preferences from the drop-down list.
Once the Preferences window has opened, use the menu at the left to navigate to Run/Debug, then Launching
Under Launch Operation, tick the check box with the following description: Always launch the previously launched application.
Afterwards, Eclipse should ask you only once and remember that choice.
#soc describes a workaround to the problem. At the moment there is no other/better way to make this to work. It needs to be fixed in future.
Luckily, this issue is partially fixed in the current nightly build of the Scala IDE. There is a fix for another problem, that disables the "Run As Java" Option: Disable JavaLaunchableTester on Scala files
It works not for all cases, for example if one right clicks on a package the known "Run As" Options are displayed. But for objects with a main method it works quite well if one uses the "Run As" Option of the Source file.

How to forbid creation run configuration in PyDev

Each time I press run button (or using shortcut for it), eclipse creates run configuration in some unpredictable way (looks like it uses currently selected file in PyDev Package Explorer, which is very strange). How to force eclipse to use only manually created run configurations and forbid to creating new one for the current project. I have 'Always launch the previously launched application' checked, but it doesn't help.

How can I make Eclipse/FDT build Main.as instead of the currently selected file?

I'm using FDT, and I want Eclipse to build my Main.as file instead of the currently selected file when I click debug/run. Is there a way to do this?
It depends on your settings and the order you've done things...
If you right click on a file and choose 'Run As' or 'Debug As', FDT (Eclipse) will use that file to build your application around.
If you have 'Always launch the previously launched application' enabled (it should be enabled by default) then FDT will always use the last used launch configuration whenever the Run / Debug button is clicked. If none exists then it will run using the currently active file. To enable this setting, go to Preferences > Run/Debug > Launching and look at the bottom where Launch Operations is.
If you have a launch configuration already created, and it sounds like you do, you'll need to adjust the 'Main' file within that launch configuration. Do this by choosing 'Run Configurations...' via the Run button drop down.
I've written a tutorial about this. It should help you get through it.
http://fdt.powerflasher.com/docs/Launch_Configuration_Tutorial