[java] Ctrl+click doesn't work in Eclipse Juno

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?

This question is related to java eclipse

The answer is


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.


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.


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.


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.


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.


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.


Go to

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

and be sure that

Enable on demand hyperlink style navigation

is checked.


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)


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


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


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

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.


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 .


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.


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.


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


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


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.


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.


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


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>


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.


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.