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?

  • Cloning GIT repository by ANT
  • Create ANT script to build on Tavis-CI and run JUnit tests on commit
  • Run batch scripts on a remote server (windows) from jenkins
  • How to debug android project from git using Jenkins frontend?
  • how to clone ssh remote repository using jgit and apache ant task?
  • How to manage a common ant build script across multiple project build jobs on jenkins?
  • Get snapshot of a git repo on a particular date
  • get size of commit from github api
  • Delete button is not working
  • How can I easily apply a bugfix on several release branches in Git?
  • git pull - can't submit merge message
  • Deleting then adding directory to branch doesn't merge correctly
  • 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.


    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.