score:23

Accepted answer

There is Copy Qualified Name function in Eclipse, it will copy the full name of the element you select (or element on cursor).

For example :

/MyProject/src/app/Application.java : when you select Application.java in Package Explorer

java.util.HashSet<String> : when you copy while cursor at HashSet<String>

However, it required you to select the element you want.

So, here is what I do.

  1. Make your Package Explorer link with editor, you can active this by click the double-arrow icon at top-right corner.

  2. Set up a hot-key for Show View (Package Explorer) ex : Alt + 1

  3. Set up a hot-key for Copy Qualified Name ex : Alt + Ctrl + Shift + c

Whenever I need these information in current file, I just press the hot-key to call my Package Explorer Since it links with editor and will always select the file in current editor, you can just copy with the hot-key. Then you can use F12 back to your editor, or simply ESC if you use fast view.

Not perfect, but it works :D

score:0

The video demonstrating the technique was prepared for Eclipse in Windows. In Linux you have to change:

  1. External Tools Configurations - Location: /home/username/path/to/script.sh
  2. External Tools Configurations - Arguments: ${selected_resource_loc}
  3. External Tools Configurations - Standard Input and Output - CHECK "Allocate console (necessary for input)"
  4. Create a script /home/username/path/to/script.sh as follows

echo $1 echo $1 > /home/username/clipboard_tmp.txt xclip -in -selection clipboard /home/username/clipboard_tmp.txt xclip -selection clipboard -o

I don't know why, but following command echo $1 | xsel --clipboard doesn't work in the script. It was checked in Ubuntu 12.04 LTS and Eclipse IDE for C/C++ Developers (Version: Kepler Service Release 2, Build id: 20140224-0627)

score:0

In Eclipse Version: 2020-03 (4.15.0)

In Project Explorer

Select your file> right Click> Copy Qualified Name Explanation

score:1

  1. Go to Project Explorer View in Eclipse which is at the left panel.
  2. Click on link with editor.
  3. After linking, your opened file will get selected.
  4. Right-click on the selected file. You will get the option 'Copy Qualified Name' which is just below 'Copy' option.
  5. Open the directory where your project resides. e.g. if your project is 'abc' and it's in the directory 'project', go to the 'project' directory.
  6. In the folders address bar, the address will be like this: D:\project.
  7. Paste in front of this address like: D:\project/abc/source/com/connect.java
  8. Delete the java file name(connect.java) and press enter.

You will be in folder 'com'.

score:2

Another option is EasyShell. It has a single entry in the context menu, under which you'll find copying of the path, opening explorer, a dos box and others (configurable).

score:3

Alt+Enter - open properties

Alt+L - go to path location

Shift+End - select path

Ctrl+C - copy

score:4

An alternative to the answer of Rangi Lin, which provides some additional functionality: The StartExplorer plugin for Eclipse. The solution mentioned by Rangi Lin doesn't work in all cases. It doesn't work in my case e.g. in the Team Synchronizing perspective in the Synchronize view. However, the StartExplorer's context menu command "Copy Resource Path To Clipboard", as well as the default keyboard shortcut for it (Ctrl+Alt+C) works also there. The advantage of this plugin is that it additionally allows you to open the file manager at the location of the selected file etc.

score:5

You can do it with a single keystroke by configuring an Eclipse external tool (a much underused tool in my opinion). Takes about a minute to configure the first time you use it but then it's always available. Here's a YouTube video demonstrating the technique.

score:12

There is yet another plugin that supports copying the path along with a number of other related functions:

http://code.google.com/p/pathtools/

Just search Eclipse Marketplace within Eclipse for 'pathtools'.

enter image description here

score:25

  • Just select the file tab and hit Ctrl+C to copy file basename into clipboard.
  • Hit Alt+Enter to bring up the file properties with absolute path and copy it manually.
  • Additionally you can use an Eclipse macro plugin that can do the steps in one go: http://sourceforge.net/projects/practicalmacro/files/

Related Query

More Query from same tag