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

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?

  • service entry keeps disappearing from manifest
  • open source svn client java library which can be used in commercial development
  • Packfile is truncated error while cloning Git repository
  • Where to git init for Java project?
  • Git doesn't recognize renamed and modified package file
  • Loading Maven dependencies from GitHub
  • How to hard reset from one git branch to other in JGit?
  • IntelliJ doesn't recognize java project after cloning
  • 3 Solutions collect form web for “This compilation unit is not on the build path of a Java project”

    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>
    

    Go to Project-> right Click-> Select Properties -> project Facets -> modify the java version for your JDK version you are using.

    if it maven project then do the below one:

    File->import->Maven->Exiting Maven Project ->Next->Root Directory -> Browse your project from Disk.

    Hope it will resolve the issue.

    Git Baby is a git and github fan, let's start git clone.