Setting a project as the main project in eclipse - 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.

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.

Why does my eclipse project not have a build path?

What is the advantage with not having a build path in eclipse? Why is that setting default when it's like something you'd never use? It seems eclipse indigo was developed to make software development as obscure as possible. I just checked out a fresh copy of the project I checked in (called dungeonworld) this afternoon from another computer and automatically nothing works, can't compile, can't choose build path, can't add jre, can't add jdk, can't add that to project properties.
Is my eclipse broken? I can't believe this is happening, such an easy thing not feasible.
Nothing above solutions worked for me so i tried below
Right click on project >> properties >> project facets >> click on java
It looks like you did not add Eclipse project metadata files to your source control system, so Eclipse doesn't know what your build path is or whether it is even a java project. You can see that the little folder on your dungeonworld project is missing the little 'j', which means Eclipse doesn't think it's a java project.
Go back to your other computer and look for the following files in your original project root...
.project
.classpath
.settings/*
Make sure all of the end up in your source control system or nothing will work right.
I have same problem, but i have solved
project right click -> properties -> java build path -> src/main/sources
all remove items on "Excluded", and then that item turn the status "(None)"
I tried below steps and it works for me.
Right click on project >> properties >> project facets >> click on java
Eclipse has a build path.
It's stored in a (by default hidden) .classpath file in your project.
You can also access it through the UI in project properties (right click on your project, properties, java build path).
Well, this is probably not your problem, but similar is happening if you are in Eclipse different perspective (for example for Python).
vs.
There where no entrys after right click on my projekt in Eclipse. How to click something, wenn build path entries are missing. So my Eclpise didn't detect my java project. I used following Maven command and after that I cleaned the project too. Now Projekt works as expected. So...
If you are using Maven, try mvn eclipse:eclipse in cmd console in your project directory! Make sure to use the path to your Maven folder for the command.
For example:
cd C:\yourEclipseProject\
C:\yourPathToMaven\apache-maven-2.2.1\bin\mvn eclipse:eclipse
This was helping me. After unsuccessful web research, a coworker told me this tip.
I just had a similar problem and I figured out that I had been choosing General Project instead of Java Project while creating a project. After I chose Java>Project it solved my problem. Maybe it'll solve yours as well.
After choosing that, eclipse automatically included java libraries as well.
It's not a good practice to commit IDE related files into source control. What if someone in team uses different IDE? It might have been only option at a time when OP asked this question.
New versions on eclipse (4.x) takes care of this automatically. Probably by observing what kind of source and build files you have in your project.
Don't know the reason. But this works for me, so posting it.
Right click on project -> 'Properties' -> 'Java Build Path'.

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

Debug Maven project in Eclipse with third party sources

I am currently developing a maven project in eclipse. The m2eclipse plugin works beautifully. It even works out of the box with debugging.
But when I am debugging open source third party libarries. It seems maven could automatically pull the source code down, but the eclipse debugger cannot resolve the currently execution point to the correct source file location.
I am sure the source code is downloaded because I can look at it and set break point. And the break point works.
But eclipse shows the source code and the currently execution point in too different windows. An example would be "TransformerImpl.class" tab window shows the source code, but the current execution point in shown in another tab window with header "Transformer.transform(Source,boolean)Line:642". This windows shows no source code.
I am felling there is some simple configuration that I am missing that could make this work. Then it will be really beautiful.
I think it is a bug introduced in one of the last m2eclipse versions. So, the workaround is to click on "Edit Source Attachment" button in the editor opened for a missing class and manually attach the source jar from the Maven local repository where it is downloaded by m2eclipse.
You should actually report this issue to m2eclipse, so developers can fix it in the future versions.

Ant build consoles get clobbered by dependent projects in Eclipse

I have a set of dependent projects in Eclipse, each with its own Ant build script. If I make a change in multiple projects, then select "Build All" (Ctrl+B), each Ant build is invoked in the correct order. But if there is an error in one project, Eclipse still tries to build the other projects also, and in the process clobbers the Ant console so that the build errors are no longer visible. This wouldn't be quite so annoying if I could open up the offending project and select "Build Project", but Eclipse out-smarts me: it won't rebuild until I open some file in the project, edit it, and save (typically I add and remove a space character wherever my cursor happens to be). An answer to any of the following questions would be welcome.
How can I configure Eclipse to (in preference order):
terminate a "Build All" as soon as any project's Ant build fails?
save all console output for "Build All" instead of resetting the console for each project?
spawn a separate console for each new instance of Ant?
allow me to force a "Build Project" even if it doesn't think anything has changed?
[UPDATE] Bonus Question:
How can I configure Eclipse so that fixing any build errors in a depended-on project counts as a "change" for the purposes of "Build Project"?
Have you tried redirecting standard out to file via a run configuration? A few screen shots to help if not... (you may try 'append' this is not in my screen shot :) )
One alternative is to have each Ant build log itself, e.g., using the following in build.xml
<record name="build.log"
loglevel="verbose"
append="false" />
Oddly, Eclipse seems to disable this logging somehow when running an Ant build.
I am not too big on ant, but can't you make the builds dependent on one another?