Eclipse/Java code completion not working
Asked Answered
B

25

659

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?

Benedick answered 26/5, 2009 at 0:43 Comment(1)
For those of you who are trying to fix this on Ubuntu, [here is the answer][1]. [1]: askubuntu.com/questions/243639/…Reena
B
1375

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
Bertero answered 26/5, 2009 at 4:24 Comment(3)
no idea how this was changed in my environment - i certainly didn't do it, but your solution works! thanks.Merchant
Just downloaded and fresh installed Eclipse 2020-12 (4.18) for macOS, and the settings were missing. Thanks, VonC, you made my day!Democratic
This had driven me nuts for years, I had to mash ^space until it cycled back to variables. I swear I changed nothing...Donee
C
86

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.
Capitulum answered 21/1, 2013 at 19:37 Comment(3)
+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.Recidivism
Wait, 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...Recidivism
+1. Note : if you try content assist in a lambda expression it may not be well supported by your Eclipse version.Proteiform
A
51

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

Almira answered 17/6, 2017 at 9:45 Comment(1)
This may make your eclipse very slow with big code base.Sudden
E
22

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.

Escobedo answered 4/5, 2013 at 5:34 Comment(3)
Please include the essential parts of your blog here, in case it becomes unavailable in the future.Ejaculate
Same problem in LXDE. Go to Preferences -> Keyboard Input and remove the Next input method shortcut.Teleplay
Same problems appears with Cinnamon desktop environment.Epexegesis
A
13

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.

Alegar answered 27/4, 2011 at 11:30 Comment(0)
P
13

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

Parabolic answered 7/1, 2015 at 10:39 Comment(1)
Thanks, this saved me a lot of headache with JNA, though it didn't stop me from badmouthing Eclipse yet again...Stalingrad
S
11

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!

Shoshone answered 30/11, 2013 at 11:53 Comment(0)
F
7

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

Furfur answered 26/5, 2009 at 0:43 Comment(0)
A
7

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 text editor.

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

Apheliotropic answered 1/1, 2014 at 4:22 Comment(0)
T
5

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.

Townspeople answered 21/11, 2013 at 18:22 Comment(0)
A
5

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.

Akvavit answered 17/1, 2014 at 21:41 Comment(0)
V
5

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
Villon answered 11/9, 2014 at 9:59 Comment(0)
L
5

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... :)

Lebensraum answered 11/1, 2017 at 9:1 Comment(0)
V
5

Running STS on Java Spring Boot projects, here's what works for me :

enter image description here

Verulamium answered 17/5, 2020 at 1:38 Comment(1)
I had exactly the same issue as Robert Brown, this solution worked perfectly for this case. Thank you.Brehm
M
5

We can change the settings as per our requirement.

Suppose we want to make java proposal as highest priority we need to do changes as shown below.

Windows > Preferences > Java > Editor > Content Assist > Advanced

Choose Java proposal and click on up button

enter image description here

Mimicry answered 26/12, 2021 at 5:35 Comment(0)
C
4

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
Cartierbresson answered 24/1, 2018 at 14:33 Comment(0)
W
4

I have run into this problem since upgrading to Eclipse 2019-09. Based on some of the suggestions above, this is what worked for me.

I had to go to Eclipse -> Preferences -> Java -> Editor -> Content Assist -> Advanced.

Java Editor/Content Assist Advanced

I found out that if I turn on any of the key binding proposals, Java Non-Type, Java, Java (Task-Focused) or Java Type proposal, then I was able to use auto complete. If I turned them all on, then not only did auto complete work, but I got duplicate methods listed. I am guessing, but I will probably used Java Type Proposals. Any clarification of what differs for these four types would be appreciated.

Weinberg answered 14/4, 2020 at 22:59 Comment(0)
F
3

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

Fluting answered 2/12, 2015 at 8:27 Comment(0)
H
3

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

Hartzell answered 7/6, 2016 at 19:5 Comment(0)
O
3

For those who use the latest 3-19 eclipse build:

It just happened to me when upgrading from Oxygen to 3-19 eclipse version, so I assume the auto-complete feature does not migrated correctly during the upgrade process.

The only solution that worked for me was to create a new eclipse workspace, and import the project/s to it. It might take a few minutes, but it worth it - comparing to the time spent on other solutions...

Olaolaf answered 3/6, 2019 at 10:19 Comment(1)
Yes for me i am unable to browse the java methods, click browse/open declaration is not working. And this is happening quite frequently, the java class files have effectively become text files. So i keep deleting the workspace and import the maven project, back into action in a minute.Indonesia
F
2

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.

Foushee answered 23/11, 2015 at 15:56 Comment(0)
S
2

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.

Scharff answered 6/11, 2016 at 16:34 Comment(0)
K
2

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.

Katharinekatharsis answered 21/12, 2017 at 17:9 Comment(0)
A
2

If you're experiencing this in an enum, or when initializing an array with anonymous classes, it's a known bug in Eclipse. See Eclipse content assist not working in enum constant parameter list.

Acarpous answered 5/2, 2020 at 0:17 Comment(0)
R
1

For me in Sep 2021 it was an odd Eclipse bug. I had a multi-line string inside an annotation in my Class. This caused just that particular class to fail when trying to code complete (even though the class compiled just fine).

Robison answered 6/9, 2021 at 13:55 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.