Why does my eclipse project not have a build path? - eclipse

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'.

Related

maven integration in eclipse new project checked out but can't navigate

I am struggling with maven in Eclipse even though I have m2e.
I checked out a maven project from CVS and cannot navigate anywhere. If I try References > Project, I get a pop up saying:
"Problems opening an editor Reason: services does not exist".
services is the name of the main project, which has sub projects within it. It all builds successfully so I am not sure why Eclipse does not work.
I suspect something related to classpath but have no idea how to edit it since it is not available from the project's properties. I actually tried to manually create a .classpath file but it did not help.
I also converted the project to a maven project but that did not help either.
Any ideas? I am using Eclipse JUNO.
I figured out my issue. I had to check out the project from CVS. Then (that's the important part), perform a maven import of an existing project within eclipse. That created maven "ready" projects where I could use all of the IDE's functionality.
Yes, you're right. If you import directly from a repository, hovering, linking and opening declarations isn't gonna work. Your solution is right, although another one more direct is use the "File->New->Other->Maven->Checkout Maven Projects from SCM". If then, you have problems because you can't select any SCM type, check Checkout Maven project from SCM - no connectors. If with connectors installed you still have problems: http://forum.springsource.org/showthread.php?102665-SCM-types-not-available-in-Checkout-Maven-Projects-from-SCM.
If you have checked out project from svn, project checked out is not generally a eclipse project thats why general functionality of eclipse does not work for the same.
To achieve the same functionality of eclipse like eclipse reader and all other shortcuts,we have to convert the checked out project to eclipse project.
Steps to Convert checked out project to eclipse project:
Right Click on Checked-out Project.
Point to Configure.
Click on Convert to Maven Project.(if checked out project is maven project)
These steps will convert the project to Maven project.
All the eclipse functionality will work for the same.
In addition to ensuring that the projects are configured as Maven projects, you may also go to Project Properties (right-click on the project in Package explorer) > Project References, and add projects in the workspace that the selected project may have references to.
I had this problem, too.
It looks like after a search-in-workspace Eclipse opened a wrong file.
I pressed Strl+Shift+H (Open Type in Hierarchy), typed in the class name, and opened it. The file opened in a new tab, and everything was navigable again.
The difference in icons is:

How can I get Eclipse to index an entire C/C++ source tree that contains multiple "make projects"?

I'm having trouble getting Eclipse to index my source code. I'm using Eclipse Helios on Windows XP at the moment.
I have a directory called src. Within it, I have a bunch of dirs, something like this:
src
-include (common headers)
-lib
-libIO (source code for this library)
-libGUI (source code for this library)
-pgms
-pgm1 (source code and headers for this pgm)
-pgm2 (source code and headers for this pgm)
Each leaf has its own Makefile. There is no top-level Makefile in src. pgm1 can and does include files from include and lib/libIO and lib/libGUI.
Basically, I want Eclipse to index my entire src directory, without having to set up a C/C++ project for every leaf in my tree. I can't seem to find a way to make this happen.
Here's my symptoms; what I'm trying to solve for:
When editing source in the pgm1 dir, it references functions that are declared in my include dir header files and defined in source files found in lib/libIO.
However, when I press F3 to get to the declaration of a function, Eclipse says "Could not find symbol 'X' in index". I can't seem to get Eclipse to find either the header declaration or the source definition for the method under my cursor (like the Java module does perfectly). Is this possible?
I had exactly same issue as OP but for some reason the menus in Eclipse I was using (Helios Service Release 2) were not "Go to Properties -> C/C++ General -> Paths and Symbols -> Source Location.".
The way I fixed the issue was :
in C/C++ view, right-click on top project name;
in the menu, select New->C++ Project;
in the window that appears, select Convert to and then select C++ project;
click OK to close the window.
Eclipse will start indexing right away. Depending on the size of source tree it may take a while but you will have the indexing working finally after that.
I faced similar situation. I solved it in this way: right-click the project in project View-->select Index-->rebuild.
I managed to solve this thanks to comments here.... I ended up recreating my project. I used the Import method to download a project from CVS, and told it to use the New Project wizard to do so. When I got the New Project dialog, I told it this was a C++ Project, and the indexing now works fine.
I still wish I could index files without having to attach a specific project type to it, but at least I found an answer.
Thanks for the help all.
Exit Eclipse. In workspace go to ".metadata/.plugins/org.eclipse.cdt.core" and delete everything in there.
in the project explorer panel, right click the project you want to re-index, then select index, then select the action you want
Indexing of files and variables under different flags is always complicated when we have a huge project, lot of files and more importantly lot of different build options. I prefer playing around with the Indexer option to help me browse the entire code.
You can find it : Project Properties>C/C++ General/Indexer.
You can choose "Enable project specific settings"
Then it's up to you to choose the options you want for your project.
For a particular build we can choose "Use active build configuration" so that only the files and MACROS are considered which are used by the build script.
Or Index all source files in the entire project.
I am using Eclipse Neon 3, here's the solution that worked for me :
go to File
New
Convert to C/C++ Autotools project
then select your project and finish.
It can take some time to finish indexing, it depends on your project size.
I have experienced problems with the indexer of Eclipse Luna when there was an unresolved friend declaration in the class declaration - it seems then that the indexer skipped indexing the rest of that class, and all references to it was shown as unresolved by the indexer.
Solution: removed the unresolved friend declaration (in my case, it was legacy code that was no longer needed).
Please try the following (my project is set up differently, so I am not sure this will work for you).
Go to Properties -> C/C++ General -> Paths and Symbols -> Source Location.
Do you see your source folder there?
I observe this behavior:
When I add a source folder and then exclude it from build, it disappears from the above list. After that the folder is no longer indexed. Re-adding it to "Source Location" solves the problem: the folder is now indexed; remains excluded from build (as intended); is visible among source locations.
I believe it is a bug -- excluding a source folder from build should not remove it from source locations list.
In Coocox IDE (Eclipse + gcc) the problem is resolved by going from file menu
Edit > Preferences > C/C++ / Indexer > Build configuration for Indexer set to Active build configuration and the rebuild the project (Ctrl R).
If the project is already converted to C/C++ and still the index is not working you can right click on the project and Index and rebuild. The project will start indexing right away.
I am using
Eclipse IDE for C/C++ Linux Developers
Version: Helios Service Release 2
Build id: 20110218-0911
I followed the suggestions above and in addition I had to mark all referenced projects (with in the work space) using project properties->Project references
The following has worked for me in Eclipse Neon:
New Project -> C/C++ -> Makefile project with existing code -> Next. Then Navigate to the code and finish the project creation. Indexing starts automatically.

The project cannot be built until the build path errors are resolved.

While compiling an android project in eclipse 3.4.2, I am getting The project cannot be built until the build path errors are resolved.
I got a temporary solution from the blog http://www.scottdstrader.com/blog/ether_archives/000921.html
The resolution was to force a resave of the selected projects (and their .classpath files):
Open the project properties
Select Java Build Path > Libraries
Add a new, arbitrary library (to be deleted later) > OK
Wait for the workspace to refresh (or force a refresh of the project)
The error(s) will go away
Remove the dummy library
The only other references I could find were to make minor alterations of contents of the .classpath file.
Is there any permanent fix for this issue?
Have you tried using Project > Clean... from the menu? This will force a new build on the selected projects in Eclipse.
1-Right CLick on your project folder, Choose Build Path > Configure Build Path
2-Select Libraries Tab and delete any arbitrary library present there.
3-Click on Add Library option, Select JRE System Library and click Next.
4-Choose last Radiobutton option Workspace default JRE and click Finish.
5-press f5 for refresh.
6-run ur program .
This what fixed it for me...
I was having an issue with my spring-core.jar.
I deleted the entire release directory located here. (I'm on win 10).
C:\Users********.m2\repository\org\springframework\spring-core\4.3.1.RELEASE
I right clicked on the project > Maven > Update project and my exclamation mark disappeared. No problems any more.
Here is the source where I found the information:
http://crunchify.com/cannot-be-read-or-is-not-a-valid-zip-file-how-to-fix-maven-build-path-error-with-corrupted-jar-file/
This happens when libraries added to the project doesn't have the correct path.
Right click on your project (from package explorer)
Got build path -> configure build path
Select the libraries tab
Fix the path error (give the correct path) by editing jars or classes at fault
This works for me: close the project then re-open it, this will force eclipse to reload a fresh project and detects the correct build path.
None of the other answers worked for me. Even after fixing my build path issues, doing a refresh, clean, rebuild, and restart (of both eclipse and the computer), I was still getting the little red exclamation point.
I fixed it by closing the project (right-click, close project) and reopening it (double-click the closed project), which seemed to force eclipse to "notice" that the build path problems had been corrected.
For my mac osx Eclipse, I followed following steps:
Right CLick on your project, Choose Build Path > Configure Build Path
Select Libraries Tab and delete any arbitrary library or anything else causing errors in Build Path.
Click on Add Library button, Select JRE System Library and click Next.
Choose last Radiobutton option Workspace default JRE and click Finish.
Clean and build your project.
get a cmd and run
mvn eclipse:eclipse
This is what worked for me:
Go to ~/.m2/repository and deleted everything there by running rm
-rf. Make sure everything is deleted.
Re-launch eclipse or STS
Right click on project -> Maven -> update project.
On my Mac this is what worked for me
Project > Clean (errors and warnings will remain or increase after this)
Close Eclipse
Reopen Eclipse (errors show momentarily and then disappear, warnings remain)
You are good to go and can now run your project
I've seen this problem a few times (got it again right now on my home computer with Eclipse 4.2).
Forcing a resave (by changing the classpath e.g. by adding a library, save, change-back) works temporarily. But the problem comes back when Eclipse is restarted :(
Nuking the Eclipse workspace from orbit will permanently fix it (until next time). But there must be a better way!
just check if any unnecessary Jars are added in your library or not. if yes, then simply remove that jars from your library and clean your project once. Its worked for me.
In Eclipse this worked for me: right click project. -> Properties -> Library Section; Add (any library at all) -> select library and click remove -> press okay.
I ran into this annoying issue with the Play framework. It would be nice if there was some way of knowing what build errors Eclipse is unhappy about, but it's not going to tell you. With one project, I was able to close the project, rebuild the Eclipse configuration with sbt eclipse, and reopen. With an almost identical project, that didn't work. But deleting the project, rebuilding the Eclipse configuration with sbt eclipse, and importing, did the trick.
If you think you've done everything correctly but Eclipse still complains about the jars, refresh the folder where the jars are and make sure eclipse knows they've been added to the project. Specifying the file path alone is (apparently) not enough
I've faced this issue a couple of times and following the below steps has resolved both the times.
1. Navigate to C:\Users\
2. locate the ".m2" folder and delete it.
Now navigate to the particular project in eclipse and Right-click on the project > Maven > Update Project
wait until the project is updated and in my case following the above steps resolved both the times.
I was getting an additional warning
The compiler compliance specified is 1.6 but a JRE 1.8 is used
Resolving this warning make the error also go away. The steps are as follows:
I right-clicked on it, then clicked on Quick Fix. From the dialog that opened I selected Open the Compiler Compliance property page, and clicked the Finish button.
(This is same as Java Compiler section.)
In this dialog I found the Compiler compliance level drop down and changed 1.6 to 1.8, and clicked on Apply and close.
I got a message box Compiler Settings Changed which asked if I wanted to Build the project now?. I clicked on Yes.
The build path error went away.
Go to > Right CLick on your project folder > Build Path > Configure Build Path > Libraries Tab > remove project and external dependencies > apply & close
Now, Gradle refresh your project.
Added below to pom.xml file and it worked eventually:
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>4.0.0</version>
<scope>provided</scope>
</dependency>
Goto to Project=>Build Automatically . Make sure it is ticked

How can I add my application to Tomcat in Eclipse?

I have a web app built with Maven.
Most of the time, I built the application using Intellij IDEA, but now I want to import the application in Eclipse to see something in this IDE.
After mvn eclipse:eclipse, I add in Eclipse the app, but when I try to add the app to the server (tomcat), I receive:
There are no resources that can be added or removed from the server
Solutions?
You need the project to have a Eclipse Dynamic Web Module facet. You can try doing this via the project properties dialog and looking at project facets, then clicking the appropriate check box. This may not be available however, so you may need to do the next thing.
Create a backup of your project and follow the directions at dzone.com. This'll allow you to modify the project facets via your eclipse .project file.
Keep in mind, once you add those facets, you cannot change them back via Eclipse. Definitely make sure you have a backup before starting.
This step worked for me:
Right-Click on the Project Name, then
Maven-->Update Project..
Click OK
After doing this I was able to see my project in Add/Remove Programs.
As mentioned somewhere else adding Eclipse WTP didn't do any good, however I performed the above step after I had already added Eclipse WTP, so I am guessing that may not be needed.
This was done for Eclipse Juno.
Hope this helps someone.
Edited: You can follow this link as above mentioned I think might have needed WTP and that add a lot of other things into the workspace.
http://blog.teamextension.com/maven-as-eclipse-dynamic-web-module-556
Check whether Maven Integration for Eclipse WTP is installed. If not, install it from Eclipse Marketplace
After installation restart Eclipse
Right click your project and Maven--> update project configuration
Delete tomcat and re create tomcat (clean tomcat,add your project,publish and enjoy)
I've got Tomcat 6, Java 1.6, and was trying to get it to work in Eclipse Juno Service Release 1's "internal server" (whatever that's called.) Here's what I did that worked for me:
(Found these instructions at http://www.mkyong.com/eclipse/eclipse-ide-tomcat-version-6-0-only-supports-j2ee-1-2-1-3-1-4-and-java-ee-5-web-modules/)
I should point out that I followed ClutchDude's instructions to make my project a Dynamic Web Module facet. It didn't work on its own for me, but maybe it was part of making it work in the end.
Using Eclipse (or other text editor), open the file
.settings/org.eclipse.wst.common.project.facet.core.xml
Find the line that reads
<installed facet="jst.web" version="3.0"/>
3.0 is for Tomcat 7.x (so says mkyong.) Change it to 2.5 (or 2.4).
I restarted Eclipse and it worked for my project.
The reason why this is happening is because eclipse by default looks for the deployment descriptor in the folder {project.home}/Webcontent/WEB-INF/web.xml where as the Maven puts them in src/main/webapp/WEB-INF/web.xml.
So when you are trying to add your project onto the server eclipse cannot find a deployment descriptor and hence you get the annoying message.
This can be solved by adding the following entries in .settings/org.eclipse.wst.common which can be found in
Project home folder in your workspace if it is a new maven project.
The folder where you already imported from if you are using Import -> Maven projects.
Make the following changes in to the org.eclipse.wst.common
wb-resource deploy-path="/" source-path="/src/main/webapp"/. Add this entry.
Edit --> property name="java-output-path"
Please check the following link from more details. http://java.dzone.com/articles/webapps-eclipse-and-maven.
The comments section has an excellent example with a working project.
This issue was fixed for me my installing additional eclipse modules. in particular, the ones related to m2e-wtp. just do a search for m2e in the plugins search listing for your version of eclipse
If you face an error like "There are no resources that can be added or removed from the server",
then
1) Go to the META_INF of your websvcsEAR and go to the application.xml.
2) Goto modules-> clickDetails and add the module that is existing. i.e., some EAR which your project demands.
3) Click ok
4) Now go to your server -> right click -> add and remove -> add your EAR.
Maybe you don't need add your application to the server's configuration. I think that you must use m2e eclipse plugin in order to launch the app.
For example, in your eclipse you will see a contextual menu called "Run as" if you right-click on your pom file. You can clicking on "Maven build" and Maven will download all the information needed to start tomcat.
I hope this helps you.
I used
mvn eclipse:eclipse -Dwtpversion=2.0
in command line in the folder where I had my pom.xml. Then I refreshed the project in eclipse IDE. After that I was able to add my project.
I was able to resolve this by removing my EAR project from my Eclipse workspace, then re-importing it.
Well, with a Spring and maven project, i got it that way:
Eclipse Version: 2019-06 (4.12.0)
Java 1.8
Tomcat 7
Yes, go to Project Properties >> Facets >> select Dynamic Web Module but dont apply yet!!!
Right under, it should appear a link Further Configuration Available. Click on it, otherwise one will have to edit .settings/org.eclipse.wst.common.component manually. Update source directory to src/main/java. (source)
Then in Facets window check Java - mine was pointing to 11 even though i don't have Java 11 installed or configured like a JRE runtime. I could only add/remove when changed to 1.8. (source). Note: That was really the problem, why don't Eclipse get this configuration automatically from the project?
Finally Eclipse creates some directories like WEB-INF and META-INF, just delete them.

Migrating From NetBeans to Eclipse

My company wants to migrate to Eclipse, I was wondering what options besides an Ant build are there to move our projects from Netbeans to Eclipse.
Tooooo ... oooo .... oooo late to answer but this works
http://www.coderanch.com/t/458555/vc/Export-Netbeans-Eclipse
i was looking for an answer my self and saw this question :)
Quoting:
Here is a little tutorial on "Importing projects from NetBeans to Eclipse".
Please try this:
PART I - NETBEANS
Open NebBeans.
Create a java project named "ToEclipse".
Build this project.
Then, NetBeans has created several folders. The important folders to us are (in my computer):
c:\User\Almir\NetBeans\ToEclipse\dist
c:\User\Almir\NetBeans\ToEclipse\src
PART II - ECLIPSE
Go to Eclipse.
Create a java project in Eclipse named "ToEclipse".
Then, Eclipse has created several folders. The important folders to us are (in my computer):
c:\Users\Almir\Eclipse\ToEclipse\bin
c:\Users\Almir\Eclipse\ToEclipse\src
PART III - WINDOWS EXPLORER
Go to Windows Explorer.
Copy the FILE "ToEclipse.jar" at c:\Users\Almir\Eclipse\ToEclipse\bin folder.
Past it in c:\Users\Almir\Eclipse\ToEclipse\bin
Copy the FOLDER "toeclipse" at c:\User\Almir\NetBeans\ToEclipse\src folder.
Past it in b) c:\Users\Almir\Eclipse\ToEclipse\src folder.
PART IV - ECLIPSE
Go to Eclipse.
Press F5 to refresh the view.
Verify that your project is there (under ToEclipse/src/toeclipse).
Say "Oh! Yes! It works!".
Run the project.
Return to 3) how many times you want!
I hope that helps you!
Kind regards,
Almir Campos
São Paulo, Brazil.
I found another easier way that worked for me at least since I had problems importing the Ant build script due to a missing javac.
Say you have your Netbeans project (src, build, dist etc) in D:/blah/
In Eclipse go to File->New->Java Project
Uncheck 'Use default location' and instead use the path where the Netbeans project is (D:/blah/) Eclipse should automatically populate everything else and link to the files as well.
I have recently 'migrated' from Netbeans to Eclipse and found it amazingly easy. The reason it was easy though is that all of our projects are IDE independent standard ant and ivy build scripts that most modern IDE's can understand. This way, we all get to use the IDE we like (yes - emacs and vi too) and their are no 'migration' issues.
The reason that I am pointing that out is that, if it is not already that way, I would recommend that you take that same path on your migration. Just create some standard ant (and ivy) build scripts. Eclipse knows how to slurp those in and there will be no future migration issues.
in MY PERSONAL experience, it was easy. I was migrating a java desktop app from netbeans to eclipse. Just copy my projects into the workspace, create the project in eclipse as a new java project and put the same name of the project in netbeans (use your workspace as location). It will recognize the project structure ( Eclipse Helios, Netbeans 6.8 )
Hope this helps. I don't know how hard it turns if you have another kind of project.
I just migrated a Netbeans 7.0 JSF web project to Eclipse. And it was easier than i would have imagined.
What i did was:
List item
Clean and build my JSF application in netbeans
Close netbeans and open Eclipse(i use galileo)
Create a new Dynamic Web Application.
Right click on the new web application in project explorer and go to import then to .WAR file
It then ask whether i want to import any of the jar files(libraries) as projects and i do not select any and just click finish.
Copied my netbeans src(source) folder /src/java/ to
the Eclipse src folder. e.g netbeansproject/medman/src/java/com to eclipseSpace/medman/src/
Next setup your server in Eclipse(i use tomcat 6.0).
And voila! it is done.
You can also check out this link. http://www.coderanch.com/t/458555/vc/Export-Netbeans-Eclipse
At my company people pretty much use either eclipse or Netbeans. I myself use both of them for various tasks. We write our own ant scripts to build and package our source so it does not matter what IDE a person uses. I would suggest that you create your own ant script to build your source, that way you won't have to depend on an IDE specific build script.