Eclipse "this compilation unit is not on the build path of a java project"
I can't get autocompletion to work in Eclipse.
I'm working on the project on svn. I set up the project in Eclipse by going into
File -> Import -> Checkout As a Project -> New Project Wizard.
I chose Enterprise Java Application. Everything seemed to work fine except instead of autocompletion working as I expected I got a popup dialog displaying the message
This compilation unit is not on the build path of a java project.
I've Googled it and everyone says that the project must be a Java project, but it is! What is the problem?
Update
The catalog structure on svn looks like this:
-Project_name
-application
-META-INF
application.xml
MANIFEST.MF
+build
+db
+deploy
+dist
+lib
+properties
+script
-src
-META-INF
someother.xml (datasource info)
persistence.xml
folder hierarchy with source files (should be package)
-web
some folders
.
.
files
.
.
-WEB-INF
faces-config.xml
jboss-web.xml
web.xml
build_win.xml
How do I tell Eclipse where the source files folder, application.xml, and other configuration xml files are?
When you have a multimodules maven project under a parent project, make sure you're not editing the file in the maven parent project.
What I did to make one of my projects to check out properly is by
1) Import your project from svn
file-->import-->SVN-Checkout Projects From SVN
2) Find your Project and then in the "Check Out As" dialogue make sure you have the radio button selected "Check out as a project configured using the New Project Wizard"
3) Go through regular steps.
The wizard pulls the project properly and then setups your eclipse....
without using the wizard I find that all hell breaks loose.....
Hope this helps...
This is what was missing in my .project file:
<projectDescription>
...
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildspec>
...
...
...
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
</natures>
...
</projectDescription>
I have this issue from time-to-time and often it's because the project wasn't marked as a java project. You can change this by going to the properties for the project > Project Facets > and selecting java. You may then need to properly configure that project, but this is probably part of the problem
I also had this problem after converting my java project into a maven project. I solved it as follows:
Right click on your project ->Project Facets -> click on Java, then Apply.