How to Add Existing Files to Eclipse Projects

This Tip sounds very basic, but still: I get asked about this about once a week. So it must be something non-obvious in Eclipse then ;-): how to add existing files to an Eclipse project. As with many things in Eclipse, there is not a single way to do something. There are two basic ways to do this:

  1. Import
  2. Drag & Drop
  3. Copy & Paste

The first is the ‘official’ way in Eclipse, the other two are much faster and easier :-).

1. Import

To import one or multiple files, select the folder/project where I want to add the files, then use the menu File > Import:

Menu File Import

Menu File Import

Alternatively, I can use the context menu:

Import Context Menu

Import Context Menu

Then use General > File System:

Import from File System

Import from File System

In the next dialog, I can browse for the files and select them to be added:

Importing Files from FileSystem

Importing Files from FileSystem

2. Drag & Drop

While the ‘Import’ method is fine, I rarely use it: too many clicks! A easier way (at least under Windows) is to drag & drop the files from the Windows Explorer:

Drag and Drop to add files

Drag and Drop to add files

3. Copy & Paste

The third way is even easier:

  1. Select the files I want to add in the Explorer/File manager, and copy them (CTRL-C on Windows)
  2. Paste them in the project/folder in Eclipse (CTRL-V on Windows)

That last method does not advanced options like if I want to link to the files, see “Link to Files and Folders in Eclipse“, but is definitely the fastest and easiest way.

Happy Adding 🙂

2 thoughts on “How to Add Existing Files to Eclipse Projects

  1. Getting the files to the right place (see above works), but I am still struggling to add the source files to the makefile. I have been assuming the makefile is automatically generated – I can add them by hand, but if the file is autogenerated, the additions will be wiped out (I assume).

    Like

    • If you are using an managed-make project (this is e.g. the default in CodeWarrior, Kinetis Design Studio or if you using the Gnu ARM Eclipse plugins, then yes, the make file is automatically generated and your new files will be automatically added. If you are using a normal make file project (no managed-make), then you have to manage your make files by hand.
      I hope this helps.

      Like

What do you think?

This site uses Akismet to reduce spam. Learn how your comment data is processed.