Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Eclipse - How to import a local source file into the same folder?

Tags:

java

eclipse

I wanted to import a file which was originally not imported into the source folder in Eclipse

What I did was:

  1. I tried placing the file directory into a source file folder, which obviously did not work.

  2. Then I right-clicked on folder->import->File System and tried to import that file, but eclipse then complains Source is in the hierarchy of destination.
    What I did in the end was move the source file out of that folder, then import it back in from a different path, which I find really redundant.

What's the best way to include a file like that? Thanks in advance.

like image 656
turtlesoup Avatar asked Jul 26 '13 16:07

turtlesoup


People also ask

How do I import the same project twice in Eclipse?

Instead of importing the project, begin creating a new project with a different name. Then change the location of the project to your new existing project. Eclipse will then let you create the project using the existing directory and content. In my opinion this is the only answer that directly addresses the question.

What is the difference between source folder and folder in Eclipse?

A source folder is marked by Eclipse as containing java sources. Then, when you compile your project Eclipse will look for your source code into all your source folders. You can make any folder become a source folder adding it to the java build path.

How do I add an existing class in Eclipse?

You need to import the class into the referencing class. Ctrl + Space (while highlighting the classname) should do the trick in Eclipse.


2 Answers

If you added (outside of Eclipse) a file to a source directory for your project, you should be able to get the file to show up in Eclipse by right-clicking your source folder in the Eclipse Package Explorer and selecting "Refresh" .

like image 115
Buzz Killington Avatar answered Sep 18 '22 15:09

Buzz Killington


you can not import into the same folder bcz no OS allow to create multiple folder of the same name in same parent. instead, you put the folder being imported somewhere else, and while importing it to workspace, check the option to "copy into workspace"

like image 33
Ankit Avatar answered Sep 18 '22 15:09

Ankit