Eclipse/Java code completion not working

483

99

I've downloaded, unzipped and setup Eclipse 3.4.2 with some plugins (noteable, EPIC, Clearcase, QuantumDB, MisterQ).

Now I find when I'm editing Java projects the code completion is not working. If I type String. and press ctrl+space a popup shows "No Default Proposals" and the status bar at the bottom shows "No completions available".

Any ideas?

Robert Brown

Posted 2009-05-26T00:43:45.363

Reputation: 5 313

1

For those of you who are trying to fix this on Ubuntu, here is the answer.

– syntagma – 2015-02-20T00:33:49.250

Answers

1 025

Try restoring the default options in 'Windows > Preferences > Java > Editor > Content Assist > Advanced'

An example of the kind of data you see in this preference screen, however not necessarily what you currently have.

eclipse content assist setting

(From Vadim in this blog post " Content Assist Duplicates in Eclipse (Mylyn)":
if have duplicate Mylyn entries, uncheck the duplicate entries that do not contain "(Mylyn)" in their name)

The Eclipse help page defines the default list to restore:

Select the proposal kinds contained in the 'default' content assist list:

  • Other Java Proposals,
  • SWT Template Proposals,
  • Template Proposals,
  • Type Proposals

VonC

Posted 2009-05-26T00:43:45.363

Reputation: 823 003

2Recently it worked for me to restart eclipse with -clean option but even this doesn't work anymore. This added to all trouble with Eclipse finally made me quit trying to work with this crappy editor. – besimple – 2015-07-03T21:13:11.523

@ImanMarashi 6 years+ after my answer, I wouldn't know for sure: you can make that an independent question, with a lot of details. – VonC – 2015-10-05T18:58:18.790

58

I'm adding an answer here in case someone else finds this on Google. Same symptoms; different problem. For me, the type caches had become corrupt.

From http://mschrag.blogspot.co.nz/2009/01/open-type-cant-find-your-class.html

  • Quit Eclipse
  • Go to workspace/.metadata/.plugins/org.eclipse.jdt.core
  • Remove *.index and savedIndexNames.txt
  • Restart Eclipse and search Ctrl+T for the offending type. The indexes will be rebuilt.

hoipolloi

Posted 2009-05-26T00:43:45.363

Reputation: 6 554

+1, this worked for me. I was also previously suffering from Eclipse thinking my project was in 1.5 despite all options saying otherwise, so it must have been corrupted during this issue. – Philip – 2013-06-30T06:51:35.803

3Wait, nevermind. After trying your method, CA works exactly once, then blows up again. Ugh. Problem persists even after recreating the entire workspace. No other solution here seems to work... – Philip – 2013-06-30T07:14:18.397

2+1. Note : if you try content assist in a lambda expression it may not be well supported by your Eclipse version. – Bludwarf – 2016-11-09T15:36:22.117

1After trying 2 3 workaround i was happy reading this comment thanks @Bludwarf – Akshay Joshi – 2017-11-11T06:17:32.880

Thanks, saved me! – TerDale – 2018-04-11T12:45:38.243

This works like a charm. Thanks a lot. – stackFan – 2018-05-22T15:41:16.887

18

For those running Xfce + having IBus plugin activated, there might be keyboard shortcut conflict.

See more info on my blog: http://peter-butkovic.blogspot.de/2013/05/keyboard-shortcut-ctrlspace-caught-in.html

UPDATE:

as suggested by @nhahtdh's comment, adding the some more info to answer directly: IBus plugin in Xfce uses by default Ctrl+Space shortcut for keyboard layout switching. To change it, go to: Options and change it to whatever else you prefer.

Peter Butkovic

Posted 2009-05-26T00:43:45.363

Reputation: 4 477

3Please include the essential parts of your blog here, in case it becomes unavailable in the future. – nhahtdh – 2013-05-04T05:40:32.450

2This solved the problem for me. You can start the settings manager with ibus-setup – Jakob Alexander Eichler – 2013-09-22T08:07:26.313

2Same problem in LXDE. Go to Preferences -> Keyboard Input and remove the Next input method shortcut. – Kshitiz Sharma – 2014-08-28T09:55:47.833

1Same problems appears with Cinnamon desktop environment. – Akkusativobjekt – 2015-11-18T10:36:24.640

10

In case someone comes here and want to activate the autocomplete function, go to

Preferences -> Java -> Editor -> Content Assist.

Then in the Auto Activation section fill in Auto activation triggers for Java:

abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ._

enter image description here

Hoa Vu

Posted 2009-05-26T00:43:45.363

Reputation: 681

10

Check the lib of your project. It may be that you have include two such jar files in which same class is available or say one class in code can be refrenced in two jar files. In such case also eclipse stops assisting code as it is totally confused.

Better way to check this is go to the file where assist is not working and comment all imports there, than add imports one by one and check at each import if code-assist is working or not.You can easily find the class with duplicate refrences.

Mona

Posted 2009-05-26T00:43:45.363

Reputation: 101

I know this is an old answer, but this seems to be my issue. I've identified the classes that are causing the problem. But now what?? – chama – 2015-06-30T12:55:33.973

9

None of these worked for me.

I was experiencing this issue in only once particular class. What finally worked for me was to delete the offending class and recreate it. Problem solved... mystery not so much!

Marc

Posted 2009-05-26T00:43:45.363

Reputation: 669

unfortunately, years after and this is the only way somtimes. – Trynkiewicz Mariusz – 2017-06-21T01:51:42.423

5

If you have installed Google Toolbar for IE, may be you can face the same problem. Because, the toolbar capture the shortcut ctrl+Space.

Shashi

Posted 2009-05-26T00:43:45.363

Reputation: 6 223

4

I faced this problem, and spent hours trying to figure out the issue. tried to follow the steps mentioned in the different answers above, the solution I found is on the same lines as Mona suggested, but slightly different. Tried to add as a comment to Mona's answer but no option was available. Issue with my eclipse was, classpath somehow got corrupted and all the jars and dependent projects were missing. after taking the latest .classpath from repository it worked fine.

Nirmal Mangal

Posted 2009-05-26T00:43:45.363

Reputation: 520

1Hey....thanq so much buddy...It works..My jre8 was unbound in my buildpath.. – Kaliappan – 2016-01-08T12:51:07.690

glad it helped you. – Nirmal Mangal – 2016-01-10T02:22:03.430

4

I had this problem and like @Marc, only on a particular class. I discovered that I needed to designate Open With = Java Editor. As a Eclipse newbie I hadn't even realized that I was just using a plain editor.

In the package explorer, right-click the file and chose "Open With".

Elroy Flynn

Posted 2009-05-26T00:43:45.363

Reputation: 1 667

4

I also face this issue but it is resolved in different way. Steps that I follow may be helpful for others.

  1. Right click on project (the one you are working on)
  2. Go to Properties > Java Build Path > JRE System Library
  3. Click Edit... on the right
  4. Choose the JRE 7

asifaftab87

Posted 2009-05-26T00:43:45.363

Reputation: 530

perfect! thanks – Shruti Dasgopal – 2017-07-31T15:07:23.560

2

Check that you did not filter out many options inside the Window > Preferences > Java > Appearance > Type Filters

Items in this list will not be appear in quick fix, be autocompleted, or appear in other various places like the Open Type dialog.

Aaron

Posted 2009-05-26T00:43:45.363

Reputation: 144

This one bit me! Thanks. – Alice Purcell – 2014-02-04T22:30:32.473

2

Another solution which worked for me is to go to Java--> Appearence --> Type Filters and do disable allenter image description here

user1889970

Posted 2009-05-26T00:43:45.363

Reputation: 548

2

In my case, Intellisense had only disappeared in a few classes in one project. It turned out this was because of a missing library on the build path (although it worked previously).

So definitely check all the errors or problems in Eclipse and try to find if a library may be missing

arnehehe

Posted 2009-05-26T00:43:45.363

Reputation: 908

2

I ran into this and it ended up being I was opening the file with the text editor and not the java editor.

I wanted to comment on https://stackoverflow.com/users/607470/elroy-flynn response but the add comment only works after I have a rating of 50? not sure WTF that is...

Thanks, Tom

Tom Orsi

Posted 2009-05-26T00:43:45.363

Reputation: 61

2

Maybe this helps other people who come across the same issue.

My setup: old Gradle project (version Gradle 2.12) made by someone else, imported using the Gradle Import Wizard into STS (Eclipse Oxygen.2 (4.7.2)).

Code completion did not work either (and I still have hollow Js at the Java files), but at least I got the code completion to work by doing:

  • right click on the project folder > Properties > Gradle > Configure Workspace Settings > Java > Editor > Content Assist > Advanced
  • check "Java Proposals in upper window.
  • 2x Apply & Close

Togepi

Posted 2009-05-26T00:43:45.363

Reputation: 33

1

For me the issue was a conflict between several versions of the same library. The Eclipse assist was using an older version than maven.

I had to go to the .m2 directory and delete the unwanted lib version + restart eclipse.

ilinca

Posted 2009-05-26T00:43:45.363

Reputation: 1 073

1

I experience problems on Eclipse Neon when editing a file which does not belong to the project directory. When I copy the same file to the project root directory, not even to the src directory, the completion starts working.

When the file is opened from a different directory, only completion for JRE works. That is for example: java. completes, but junit. does not.

Jarekczek

Posted 2009-05-26T00:43:45.363

Reputation: 4 949

1

Once you have you configuration checked and completion is still not working:

  • make sure you have the right directory structure.

Do you see the right icon beside the file?:

enter image description here

It will tell you how the file will be treated by Eclipse:

enter image description here

I am posting this answer as I had that story with with Maven webapp artifact. By default Maven-WebApp does not create folder for sources and I put my Java into resources, wondering for 5 minutes what was going on... :)

Witold Kaczurba

Posted 2009-05-26T00:43:45.363

Reputation: 2 705

1

Just in case anyone got to a desperate point where nothing works... It happened to us that the content assist somehow shrunk so no suggestion was shown, just the "Press Ctrl+Space for non-Java..." could be seen. So, it was just a matter of dragging the corner of the content assist to enlarge the pop-up.

I know, embarrassing. Hope it helps.

Note: this was an Ubuntu server with Xfce4 using Eclipse Oxygen.

tete

Posted 2009-05-26T00:43:45.363

Reputation: 41