user443854
user443854

Reputation: 7453

How to find package by name in Eclipse?

What is the fastest way to navigate to Java package in Eclipse? I am looking for something similar to what Ctrl+Shift+T does for classes.

Edit: Ctrl+H works, but it is of limited use. For one, there is no easy way to navigate to search result, because it is not clickable.

enter image description here

I am still missing the Ctrl+Shift+T type of functionality.

Upvotes: 19

Views: 38028

Answers (5)

jmiserez
jmiserez

Reputation: 3109

Ctrl+Shift+T works for packages too: Just type the package name and then a dot and it will show all classes in matching packages. Start with a dot or star in order to do prefix matching. It's important to end the search string with a dot, otherwise the last word will be used to match against class names:

com.sun.mail.
.sun.mail.
*un.mail.

shows all classes in packages beginning with com.sun.mail (also matches com.sun.mail itself). Result: 147 classes from "ACL" to "YoungerTerm"


com.sun.mail.ascii
.sun.mail.ascii
*un.mail.ascii

shows all classes in packages beginning with com.sun.mail AND whose class name begins with "ascii". Result: 1 class ("ASCIIUtility")


com.sun.mail.ascii.
.sun.mail.ascii.
*un.mail.ascii.

No results (there is no package "com.sun.mail.ascii")

If you have "Link with Editor" set in the "Package Explorer" view, just select any of the matches and the package explorer will expand to the package. You can get to the root package with (select the package explorer first, e.g. using Ctrl+F7).

Upvotes: 1

Emanuel
Emanuel

Reputation: 47

Try

'Navigate' -> 'Go To' -> 'Package...'

from the menu, probably this is what you are looking for. Of course the above sequence can be performed from the keyboard as a series of standard menu shortcuts. If you prefer to access that functionality via a special direct shortcut (which is not defined by default in my eclipse NEON.1), you can define one via

'Preferences' -> 'General' -> 'Keys'

Upvotes: 5

Ashish
Ashish

Reputation: 208

Click on the root package and start typing the name of the package you are looking for.

Upvotes: 1

Kent
Kent

Reputation: 195179

Ctrl-H

shows the java search dialog, there you could choose "search For" as package, then type name in inputbox.

Upvotes: 21

Jivings
Jivings

Reputation: 23260

I don't think there's one to jump to a package, what would you want to open? Ctrl+H opens the search dialog which you can use to search for packages.

Upvotes: 1

Related Questions