Reputation: 42799
Often I would like to copy the fully qualified class name of the class the is open in the Java file editor in Eclipse.
There is a similar question: How do you get the fully qualified class name in Eclipse? but all the answers only work for classes you use in your source code but not for the Java class file currently open in the editor.
There is also an menu entry called "Copy qualified Name" in the context menu of the file element shown in the Package Explorer
view, but if you execute this you only get the path name within the current project and not the class name.
How can I get the fully qualified class name separated with dots for an arbitrary Java file in a project or for an Java file that is currently open. For example if I have the file src/min/java/com/example/MyClass.java
open in the Java editor how can I get directly the class name com.exmaple.MyClass
?
Upvotes: 0
Views: 825
Reputation: 21
Pretty much what the previous answer said. I however have shortcuts to do that.
Ctrl+Shift+S
to focus/show the current file in the Package ExplorerCtrl+Shift+C
). It is listed in the available commands of the Keys dialog.Upvotes: 2
Reputation: 20924
Highlight the class in the Outline view and right click the mouse. In the context menu, there is menu item Copy Qualified Name
I am using Eclipse 2021-03
You can also right click on any class name in the editor window. Copy Qualified Name appears in the context menu.
Upvotes: 1