Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 642
Милош Керкез Avatar asked Aug 20 '14 09:08

Милош Керкез


People also ask

What is build path in Java project?

Build path is used by the compiler to resolve dependencies and build a project. Classpath is used during runtime when running a project in order to find necessary dependencies. Build path is configured on the Java Build Path property page of a project.

How do I fix Eclipse build path?

Procedure. In Eclipse select the web project and right-click Build Path > Configure Build Path. This will display the Java Build Path window. Add the CICS and Liberty libraries, click Add Library > CICS Liberty libraries > Next > Finish.


2 Answers

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>
like image 117
Loganathan Mohanraj Avatar answered Nov 02 '22 16:11

Loganathan Mohanraj


Another alternative to Loganathan Mohanraj's solution (which effectively does the same, but from the GUI):

  1. Right-Click on your project
  2. Go to "Properties"
  3. Choose "Project Natures"
  4. Click on "Add"
  5. Choose "Java"
  6. Click "Apply and Close"
like image 27
Pradeep Anchan Avatar answered Nov 02 '22 15:11

Pradeep Anchan