28

For every version of Eclipse I've used prior to Juno, ctrl+click would find the declaration of a variable/class/method. It was an extremely useful feature when dealing with a large code base. How do I get Juno to do this?

5
  • I'm using Juno and it still works for me. Perhaps you have a key conflict?
    – Ted Hopp
    Aug 2, 2012 at 0:42
  • 1
    If you press F3, does that find the declaration of the currently selected variable/class ? Also, which OS are you in ( Linus / OSX / Windows 7 ?)? Which flavor of eclipse are you using (J2EE, Classic etc) ? Can you point me to the exact download from here : eclipse.org/downloads/index-developer.php ? I'll try replicating your environment and see what happens. Aug 2, 2012 at 6:13
  • What language are you working in? Is it the same workspace as before?
    – nitind
    Aug 2, 2012 at 7:33
  • Might be related: stackoverflow.com/questions/18227733/… Nov 7, 2013 at 16:26
  • 1
    I encounter the very same problem in SpringToolSuite 3.6.3 which is built on eclipse Kepler SR2 (4.3.2). The Hyperlinking settings (see Answer below) are correctly set. Also the F3 key works. But Ctrl-Click not. Navigation to types etc. work, but not to the declaration of members.
    – Heri
    Feb 19, 2015 at 10:07

23 Answers 23

37

I can confirm that Ctrl + click works fine with the following :

Eclipse Java EE IDE for Web Developers.
Version: Juno Release
Build id: 20120606-2254
Operating System : Windows 7, 64 Bit

What do you have for the following preference ?

On Window -> Preferences -> General -> Editors -> Text Editors -> Hyperlinking -> Open Declaration

Here is what I had for a new workspace in Juno :

enter image description here

Update

I have not experienced this in the recent past, but I vaguely remember encountering this problem in previous Eclipse releases (Galileo and earlier).

All of what follows is worth doing only if we are sure that it's a problem with the Eclipse workspace. A quick way of checking this is to restart eclipse with a new workspace (Do this by going to File -> Switch Workspace -> Other... and choosing the path to a folder which is preferably empty and different than the current workspace folder).

If things worked in the new workspace, my fix then was one of the following, in increasing order extremeness :

  1. Re-start eclipse (Yup, sometimes that is all it took)
  2. Re-start eclipse with the -clean parameter to clean out the workspace ( See this). This might specially be worth doing if you used a workspace from an older version of eclipse.
  3. When the above failed, and I just had to use my existing workspace, I backed up my workspace folder and restarted Eclipse after deleting WORKSPACE_FOLDER/.metadata/.plugins/org.eclipse.jdt.core
1
  • -clean option worked for me. I also noticed that I had the build automatically set, unset that, clean the project too, and rebuild. Further, I have the eclipse copied from windows to ubuntu along with the project, the jre of the project was not properly bound. Anyways try all-- goodluck
    – qartal
    Mar 31, 2017 at 14:10
13

For me it helped to simply close the edited source file and reopen it. If this doesn't work THEN you can try restarting whole IDE.

2
  • Confirmed for Version: Juno Service Release 2 Build id: 20130225-0426 . Had multiple editor windows open. Ctrl-click worked only for some of the files. When closed and re-opened, the navigation worked again.
    – user77115
    Aug 27, 2013 at 12:40
  • I use ADT wich uses eclipse and this happens to me all the time. I've always solved it by closing the IDE but your answer is a better solution. Thanks!
    – Ejmedina
    Oct 4, 2013 at 20:18
5

For my situation I solved this problem by going to the project properties, select "Java Build Path", and then removing source folders that does not exist anymore.

1
  • For my issue, it was build path related, but it was resolved by closing one of my referenced projects that I guess caused the problem. Typically when this happens the IDE will complain with an error for the project if the dependent referenced open project has an issue (replaced by an Ivy jar instead of the project if the project was closed), but it didn't in this case. Once I closed the project and resolved it was fixed.
    – Marcus
    Sep 4, 2014 at 21:24
4

This bug is really annoying..

The only thing that did the trick for me is deleting the project from the workspace, then deleting the .project and .classpath files and then re import it back to the workspace.

Hope it will help others.

3

I had the same issue with PDT in eclipse, I fixed it by removing my include build paths and adding them again.

1
  • This worked for me as well on Eclipse Kepler, PDT, Ubuntu. I had made changes to ownership a number of times and Eclipse could not write to the project folder. Deleting the .buildpath and .settings folder allowed the project to rebuild. Although I'm not sure if it would have been easier to do Project > Clean. Not sure if it will have the same effect though.
    – stormwild
    Oct 23, 2013 at 6:45
2

The solution for me was to configure the build path to include the project itself.

  1. Right click on open project.
  2. highlight build path
  3. click on Configure build path…
  4. click on Source
  5. Click Add Folder… button.
  6. Put a check mark next to your project.
  7. Click OK.

If necessary, click the project menu and choose the ‘clean…’ option to rebuild.

2

I found resolving issues with the project's Java Build Path settings fixed this issue.

Right-click the project, select Properties, select Java Build Path.

(NB: I'm using Eclipse Kepler Service Release 2 on Windows 7)

2

If you're working on a large project and are working with a repository, you could just have the file opened via the wrong project, I just had two instances of the file open, where one was the one where I couldn't do Ctrl + click, while on the other file I could Ctrl + click on it successfully.

2

I was facing the same issue in eclipse. I verified preferences and build path and also no error. Tried closing and opening the eclipse but nothing worked. Even I could not run debug configuration. I created a new workspace and Ctrl+click / +click (Mac os) was working fine.

Hope this may help someone.

2

I had the same issue, and solved it the following way. My issue came because I imported a project from Git, which wasn't having the project file. So Eclipse was not recognizing the project as a java one. Ctrl+click was not working and so there was the F3 issue.

Solution:(not a direct one. but solved my issue)

  • import -> projects from git -> from URI -> select the new project wizard
  • so an empty project with src folder will be created.

  • then copy all the src files in to the folder manually.

2

Go to

Window -> Preferences -> General -> Editors -> Text Editors -> Hyperlinking

and be sure that

Enable on demand hyperlink style navigation

is checked.

1

I faced this issue several times. As described by Ashutosh Jindal, if the Hyperlinking is already enabled and still the ctrl+click doesn't work then you need to:

  1. Navigate to Java -> Editor -> Mark Occurrences in Preferences
  2. Uncheck "Mark occurrences of the selected element in the current file" if its already checked.
  3. Now, check on the above mentioned option and then check on all the items under it. Click Apply.

This should now enabled the ctrl+click functionality.

1

Sometimes if a file is too large, then for Scalability purposes, the navigation is disabled by Eclipse. For me it happened with Eclipse with C++

It can be enabled by Window->Preferences->C/C++/Editor/Scalability and then under "Scalability mode settings' uncheck everything.

Eclipse Settings

0

I encounter this problem when creating workspace/project in eclipse 3.7.2. Then I open it using Kepler (4.3). So simply open the project by the eclipse version you created it (3.7.2 in my case) solves the problem. Hope it helps.

0

I had same problem; i tried to Change in preference, clean work space etc. nothing worked. Solution: Finally i found there is error in class path configuration; after fixing this everything became normal.

0

On my system, Ctrl+click brings up the right-click menu instead of opening the declaration. However, if you hold Ctrl and hover the mouse pointer over the variable/class/method name, a small boxed menu appears with "open declaration" at the top. You can move the pointer down and click that item to get the desired effect.

I'm running Ubuntu 14.04 through VMWare on OS X.

0

I'm having the same issue in Eclipse Luna in my Ubuntu VM, but I just tried to Ctrl+click on a method and it worked (even though my mouse cursor didn't change to a pointer).

0

You need to rebuild your workspace using CTRL+B. I a problem where I'd be able to go to the function declarations but for some I wouldn't. After a rebuild, I could do all. I hope that helps.

0

Please check your .classpath file as well. Some times Eclipse do not redirect when using "ctrl+click" to Class or method if classpath is not proper. I had faced same issue in Eclipse Mars but it got resolved when I got proper .classpath file at my work location.

0

If the project is a Maven project, make sure that the java class you have open is inside src/main/java.

0

I had the exact same issue while working on a GIT based project. I was able to resolve by changing the way i was importing the project in the workspace.

Wrong way : Import project to workspace from GIT perspective , like right click on the GIT URL and selecting the option import which was not recognizing the project facets.

Right way (which resolved my issue): clone the project in GIT perspective , change to JEE Perspective , then import from file > import > Existing Maven Project .

0

I had similar issue, along with this I found that java build path in project properties was missing. Project pulled from repository did not had .project file and eclipse created a default .project file, I copied content of .project.xml from other working project and removed the unsed imports, After which everything worked fine

<projectDescription>
<name>XYZ</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
    <buildCommand>
        <name>org.eclipse.wst.jsdt.core.javascriptValidator</name>
        <arguments>
        </arguments>
    </buildCommand>
    <buildCommand>
        <name>org.eclipse.jdt.core.javabuilder</name>
    </buildCommand>
    <buildCommand>
        <name>org.eclipse.wst.common.project.facet.core.builder</name>
    </buildCommand>
    <buildCommand>
        <name>org.eclipse.wst.validation.validationbuilder</name>
    </buildCommand>
</buildSpec>
<natures>
    <nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
    <nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
    <nature>org.eclipse.wst.common.project.facet.core.nature</nature>
    <nature>org.eclipse.jdt.core.javanature</nature>
    <nature>org.eclipse.wst.jsdt.core.jsNature</nature>
</natures>

1
  • @Andronicus I have edited my post, Earlier i was getting error while pasting code. please have a look
    – Kunal
    Dec 31, 2019 at 5:15
-3

If your build path is correct, the ctrl + click will work

1
  • 1
    My build path is correct, and ctrl click does not work!
    – Charbel
    Oct 15, 2014 at 10:35

Not the answer you're looking for? Browse other questions tagged or ask your own question.