Eclipse autocomplete not working in some Java files

前端 未结 8 1527
深忆病人
深忆病人 2020-12-25 11:02

I have noticed that autocomplete is not working in some of java files in Eclipse. Also, the files where autocomplete is not working, display a hollow \"J\" as the icon for t

相关标签:
8条回答
  • 2020-12-25 11:36

    Neither Restoring Defaults or my build path (file was already in package directory w/other files where auto-complete was working) fixed problem. Fix for me was to close the file explicitly (right click on file name in tab) and re-open. Interestingly, just re-starting Eclipse didn't work either.

    0 讨论(0)
  • 2020-12-25 11:37

    As an addendum to the @VonC answer, make sure that the Java files are part of the Inclusion pattern. I had a case where a build process was creating the project while only including .js files and not the Java files:

    Shows Eclipse Include without Java files

    You can manually edit the inclusions via the Edit button. In my case, a fix was made to the build script to make it permanent.

    0 讨论(0)
  • 2020-12-25 11:46

    some answers (restore defaults) above do not work for some adt bundle installs as of jan '13.

    in those cases, go to

    Window -> Preferences -> Java -> Editor -> Content Assist -> Advanced

    and tick on the JAVA PROPOSAL options.

    0 讨论(0)
  • 2020-12-25 11:47

    Since this question is highly ranked on Google, I will add a solution to fix general auto complete issue, not for 'hollow J' ones.

    Try Window (Windows/Linux) or Eclipse (OS X) -> Preferences -> Java -> Editor -> Content Assist -> Restore Defaults

    also

    Content Assist -> Advanced -> Restore Defaults

    0 讨论(0)
  • 2020-12-25 11:47

    Make sure you have the right directory structure. I believe that:

    • Hollow J icon beside Java file - will not be build
    • Normal J icon beside Java file - is a file to be build.

    I made a mistake when I created webapp artefact. By default it does not create folder for Java, but for resources. I mistakenly put my sources there. Have a look - see the difference.

    0 讨论(0)
  • 2020-12-25 11:51

    In this following picture, MyClass.java has a hollow J, because it is explicitly excluded from the sources to build:

    alt text

    Could you go to the properties of the project, "Java Build Path" Section, "Source" tab and see if some exclusion filter has been set ?
    It is usual for instance to define:

    **/Test*.java
    

    to exclude at first building any unit-test class (when you have a large set of sources and do not want to be presented with Test classes during auto-completion, or do not want them considered during source searches).

    0 讨论(0)
提交回复
热议问题