I wanted to import a file which was originally not imported into the source folder in Eclipse
What I did was:
I tried placing the file directory into a source file folder, which obviously did not work.
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.
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.
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.
You need to import the class into the referencing class. Ctrl + Space (while highlighting the classname) should do the trick in Eclipse.
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" .
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"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With