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

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.

Related

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.

Setting a project as the main project in eclipse

Can any body tell me how to set a java project as the debugging main project in eclipse IDE.It always can't run the newly coded project because of another existing one is trying to run. Is there any option like "set as main project" option in netbeans
Thanks,
Not 100% sure I know what you are asking, so I am taking a bit of a guess. Under Eclipse "Preferences", you can go to "Run/Debug-->Launching". In there at the bottom there is a section called "Launch Operation" that gives you some control over what Eclipse launches.
This may be what you are looking for.

How can I clean up Eclipse "run configurations"

I set my java runtime options in Eclipse's Window > Prefs > Java > Installed JREs > Default VM Arguments. Since this setting is sufficient for all my main() entry points, I do not bother with customizing the "run configurations". It looks like nice flexibility but I probably will never need it. I was worried that I would have to repeat my VM arguments in the run configurations and so I started to copy my VM arguments but after an experiment it seems that I do not have to. Now I will have the opposite worry that I have some unintended customizations.
To eliminate the second worry, is there a way to eliminate the clutter visible in the Run drop down menu? What about the "Launch configurations" visible in the JAR export dialog? Is a run configuration the same thing as a launch configuration? How do I eliminate the multiple launch configurations?
I am on Eclipse Indigo on Ubuntu.
Edit After I manually delete all the run configurations, and proceed to do an export, buttons are greyed-out so I can't proceed. When I select the launch configuration drop-down, I end up with only one choice, from an unrelated project. I then created a run configuration for the real main entry point for the current project. I expect the clutter will return as I continue to use Eclipse.
One simple way would be to organize your projects by Eclipse workspace, which would limit the "run configurations" list only to the project referenced in a given workspace.
Switching workspaces would reset that list to the ones recorded for the projects of the new workspace.
Note: the OP's answer regarding launches file location isn't the only location possible.
The official one is:
${WORKSPACE}/.metadata/.plugins/org.eclipse.debug.core/.launches
But you can copy them enywhere else you want (as explained in "How do I save Eclipse launch profiles across workspaces?"), either by manually copying those files or by sharing them:
See "Which eclipse files belong under Version Control".
Once you know where they are saved, a simple delete is enough to make them disappear from the launcher menu.
The answer comes from #Francisco Puga
Experimental evidence shows that deleting "launches" seems to make run configurations disappear so it would seem that they might be synonymous.

Why does Eclipse keep creating a new Run Configuration?

I am writing some scripts in Eclipse 2.7 RC4, using the latest Groovy Eclipse plugin.
Everything works fine except that I have a Run Configuration that I created that passes 2 arguments to the script but every time I click the Play button to run the project, Eclipse creates a new Groovy Script Run Configuration called "Server (1)". If I click the Play button again, Eclipse creates another Run Configuration called "Server (2)", etc.
So, every single time I want to run my project, I have to go in and delete the last run configuration it made.
Why does Eclipse do this? Can't I lock the configuration so that it wont change?
I realize this question is quite old but it's still an issue that happens (as it was happening to me today) I played around with it a little and found that in the 'Run Configurations' window where you can set Arguments/Classpath variables etc there is also a tab named Common. I found that within this there is an option called "Save as" and if the 'Shared File:' option is selected (pointing to the exported launch configuration) it will keep creating new Run Configs every time you run it. If you instead select the Local File option and Apply the changes, I believe you will stop seeing new run configs saved each time. This worked for me, at least!
This is probably a bug in Groovy-Eclipse in that it is not recognizing that an existing launch configuration is the "same" as a new one.
Can you get around this by simply re-using the old on explicitly, ie- by clicking on the little arrow to the right of the run button and choosing the old configuration:
I am seeing the same thing for Java and Scala test programs I created in Juno version of Eclipse (latest as of Nov 2012). Very irritating to have to delete all those run configurations explicitly.

have IntelliJ IDEA refresh the project and detect changed files

I'm using Eclipse for development because of all the things IntelliJ can't do (e.g. highlight all instances of a variable) and because IntelliJ is dog slow over a remote connection. But because I still don't have Maven integrated completely into Eclipse, I have to switch back to IntelliJ to compile and run my project using Tomcat.
How can I tell IntelliJ to detect all files that have changed on the file system and recompile them? (I don't want to manually open each changed file to get IntelliJ to detect the change.) In Eclipse I would just Refresh the project tree [1]...
Footnotes:
Eclipse has a feature (named "Refresh Using native hooks or polling") which you can enable to automatically detect changes and synchronise the perspective when any underlying changes are detected in the filesystem (see images below). This is quite handy and eliminates the need to manually refresh the project when using build tools - where files/directories get created in the project directory structure.
Is there anything similar for Intellij (explicit setting or otherwise) that eliminates having to click a button to synchronize the view with filesystem changes?
You can use the "synchronize" button (two yellow arrows) or in short Ctrl+Alt+Y
Intellij can highlight variable instances, you just need to enable it .
Further, if you invoke compile project, Intellij will just compile changed files (and hotswap when possible, if you are in debug mode & deploying to e.g. tomcat)
Right click on your Project in the left pane and click on "Synchronize"
You can see the status in the round circling icon at the bottom left of the IDE
I know this question was posted a few years ago, but maybe this info will help someone in the future. I was actually looking into a similar issue, and doing the following worked for me:
Go to Settings > Build, Execution, Deployment > Compiler and make sure "Make project automatically" is checked.
Click File>Synchronize (or) shortcut ctrl+Alt+Y
There is a synchronise button in the tool bar. Click it and it will refresh the project explorer