0

I have found number of questions on this topic, some with answers but in my case not a single one was helping me resolve this problem. Or at least, not a single one that was clear to me, eclipse beginner.

But I figured out my problem and here is the description of it. I will also post answer.

I have a eclipse maven project. I notice that if I open my .java file and try to edit it by typing something like obj., I get error "This compilation unit is not on the build path of a Java project." This error is then followed by the "Failed to Download Index" error box like below:

enter image description here

pixel
  • 9,653
  • 16
  • 82
  • 149

1 Answers1

5

A maven project (depending on whether it is type of a web or some other project) has structure like below:

enter image description here

In order to get your code completion working and as explained in the red below, make sure you open and modify java file in your MyProject-war project, not the one in your MyProject > MyProject-war project.

When you open these two files in the editor, you will see that the one has bold "J" in it, while the other one has a hollow "J" in its tab like below:

enter image description here

The one with "J" in bold will have proper code completion. You should be able to type things like String. or yourObject. and get code completion.

The one with hollow "J" wont show code completion but will show you the info and error above.

pixel
  • 9,653
  • 16
  • 82
  • 149