This compilation unit is not on the build path of a Java project

Милош Керкез picture Милош Керкез · Aug 20, 2014 · Viewed 113.1k times · Source

When I try to use ctrl+space this error is shown:

This compilation unit is not on the build path of a Java project.

I see that there are similar topics but my work environment is Eclipse and i pull my project from Git (I import project as general project) and i use Apache Ant. Can anyone help me?

Answer

Loganathan Mohanraj picture Loganathan Mohanraj · Aug 20, 2014

Since you imported the project as a General Project, it does not have the java nature and that is the problem.

Add the below lines in the .project file of your workspace and refresh.

<natures>
      <nature>org.eclipse.jdt.core.javanature</nature>
</natures>