How to make an existing directory into an eclipse project - eclipse

I have a project I am working on. I have decided to try working with it in Eclipse. There is already a directory, under version control where all the code resides. I am having a rather strange problem. I cannot find any way to just start using an existing code directory as an eclipse project. All I can find is how to import existing source into a new project or check out source from version control into a new project. How do I make an existing directory into a project?
My project is a Django web app if it is any help

In the New Java Project wizard, uncheck the checkbox that says Use default location and the use the Browse button to find your directory.

It is pretty easy to do. Go to File->New-> Project. In the Project wizard, choose the type of project you want and then be sure to unclick the 'Use default location` checkbox. Browse for your folder in the widget that then becomes enabled. Click finish after that.
Alternatively, you could create a brand new project workspace in a new location. Then, assuming Java as your project type, you can open up your project properties and add as a source folder your existing directory. To do this, use the 'Link Source' button on the Java Build Path -> Source tab of your Project Properties dialog.

My Method:
I clone this file to new project directory , and rename Project-Name to my project name, after that i import new files and directory from Eclips
File Name: .project ( Use Notepad for make this file...select Save as type to All Files (*.*) and write file name like: .project )
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>Project-Name</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
</buildSpec>
<natures>
</natures>
</projectDescription>

Hope this link answers the original question of this thread.
http://help.eclipse.org/juno/index.jsp?topic=%2Forg.eclipse.platform.doc.user%2Ftasks%2Ftasks-45.htm
Creating linked resources
Folders and files can be linked to locations in the file system outside of the project's location. These special folders and files are called linked resources.
To create a linked folder:
In one of the navigation views, right-click the project or folder where you want to create the linked folder.
From the pop-up menu, select command link New > Folder.
Specify the name of the folder as it will appear in the workbench. This name can be different from the name of the folder in the file system.
Click Advanced.
Check Link to alternate location (Linked Folder).
Enter a file system path, or click Browse to select a folder in the file system.
Click Finish.

Probably not the way most people would go about this, but I like all of my eclipse projects in one place but don't necessarily have my source in my workspace directory. Maybe there is a built in way to "symlink" in eclipse, but I sometimes end up with the project folder in the workspace, with the "src" symlinked to the actual source directory somewhere totally different. That's my personal preference anyway. If you too are on a *nix machine a simple
ln -s /path/to/source src
will do from your project directory.

You know, it is not so simple question. Depending on your project type (jar, web module, ear and so on) different structure and configuration files are used by eclipse. So the first really interesting question is that what is your project type? The basic solution after it to create a new project, and define the directory of your source code as project root. Then you will see what else to change (for example source path settings, classpath and so on). So how does your project look like? Can you proide structure tree of folders?

Since you are using Django you should first set up PyDev in Eclipse. You can install it from the market. Then you want to configure the PyDev Python interpreters to find your installation of Django (http://pydev.org/manual_101_interpreter.html). Make sure to provide the explicit path to the Django folder if your Django is not installed in the default location.
Once these things are ready you can select File > New > Other, then select PyDev Django Project from the PyDev sub directory.
Click next and here is the sweet part: Uncheck 'Use default' (as previously stated) and then find your Django project directory. Be sure to select the right project folder (ie: the folder that contains manage.py). When you have the right folder selected Eclipse/PyDev will recognize that a project already exists and make mention that it will use those files. Click Finish.
Then there is a DB form that asks about your DB settings. If you already have a settings.py file then this seems to make no changes (as it should not). So fill it in or don't. But this is the last step.
Then you should be able to view and use your existing project in Eclipse!

I just created a pom.xml by hand and imported the project as an existing Maven project in Eclipse. It even works for nested projects without problems.

Use "import - existing projects into workspace". This works for my case.

Right click on a project -> Properties.
Open project location in explorer, there's a little icon next to path.
Put your folder/file structure in there and refresh the project in eclipse.

Related

I need Netbeans help. NO project's -src node appears so no source files--only -Libraries node shows

I hope it's OK to ask this here. Netbeans forums isn't responding. If not, I'll delete this or ask for it to be deleted. I'm desperate so I'll face the wrath, if any.
I moved my Netbeans projects folder from one directory node to another to make backing up all my stuff easier. BAD MOVE.
Now when I open a project using Files | Open project (ctrl-shift-O) NO source files appear because there is no "+Source Packages" node to expand.
It looks like this for all projects, e.g. one named GBL:
Projects
-GBL
+Libraries
It doesn't look like this anymore:
Projects
-GBL
+Source Packages (How do I get this back?)
+Libraries
The Netbeans Properties for each project shows me the path it's using. Windows 7 Explorer shows me that the src, build, and nbproject folders contain files and ALL the source files are in the src folder for that path.
What have I done and more importantly what should I do to get back to being able to open a project normally?
(I've tried recreating the original Netbeans folder and using Windows Explorer to copy an entire project folder into it but: same result--all I see is the Libraries node under the project's name node.)
I just tried to Clean (and also Build) to see what would happen. Error:
ant -f C:\\Users\\Dov\\Documents\\NetBeansProjects\\BasicShirt -Dnb.internal.action.name=build jar
C:\Users\Dov\Documents\NetBeansProjects\BasicShirt\nbproject\build-impl.xml:[u]231[/u]:
Must set src.dir
I just Set Configuration by right-clicking the project's name and provided a path to the src folder.
NOW I SEE MY SOURCE FILES BUT NOW THIS line in the .xml file is flagged with similar message:
<fail unless="[u][b]test[/b][/u].src.dir">Must set test.src.dir</fail>
NOW what do I do? (Netbeans 7.4.)
If I could get rid of the 7.4 automatic creation of +Test Packages, I might be OK.
If you can help, I'd be very happy.
(I'm considering re-installing 7.3 if available or removing and reinstalling 7.4 and try to avoid the "testing" requirement, but there goes all my many tweaks of 7.4.)
Well, after considerable frustration with the problem, I solved it, essentially.
It's here, in total. My synopsis plus how it helped me follows. In short, I had to set up a new java project based on existing sources using the New Project Wiz and simply direct Netbeans to the sources.
File > New Project
Choose Java Project with Existing Sources.
Type a (new) project name and ...
... make the Project Folder contains the path to where you want the new project to be stored. (For me, this is the folder where Netbeans has been able to find my sources.)
Click Next for the Existing Sources page of the wizard and ...
5a. ... in the Source Packages Folder pane, click Add Folder and ...
5b. ... navigate to your sources and select the source root folder.
Clicking Next goes to the Includes/Excludes pane, which I didn't need to use.

Eclipse project already exists

I deleted a project in my workspace, then tried to create a new project with the same name. Eclipse told me that it overlaps the location of another project (the one I just deleted). How do I fix this?
This is what I did.
Go to Window --> Show View --> Project Explorer
Then right click on the project name that you want to delete and Click Delete.
In the dialogue box, check 'Delete Project Contents on disk'
It worked. I was able to create the project with same name again.
I had the same problem with the IBM Integration Toolkit, which is based on Eclipse. The problem also occurs in Android Studio, which is also based on Eclipse. crazyscot seems to have the right answer at A project with that name already exists in the workspace eclipse and his solution worked for me.
You need to open up the Project Explorer view (it may already be open) and delete the project from within there.
Go to Window >> Preferences >> General >> startup and shutdown >> workspace
theen select Recent work space then click Remove and close the program and open it again
You have to manually delete the project folder from your "workspace" directory (wherever you have defined it to be).
there will be a file .project xml file in the project and its content looks like
<projectDescription>
<name>ProjectName</name>
.
.
.
</projectDescription>
here ProjectName is the name of project you can change it to whatever you want.
First you create a project in some other location with the same name of your project as before.
Now delete this project by right clicking on project > Delete.
Do not check the dialog "Delete Project Contents on Disk".
Now you move your newly created project through file manager to the original location(location where you are not able to import your project).
Then import the project from the newly moved location(location where you are not able to import your project).
After deleting the project from Eclipse IDE(Project Explorer), remove it from work space folder as well. Workspace folder path - C:\Users\username\workspace (it can be different for your system).
try moving the project and try importing
go to tab window>preferences>search workspace> then make sure in last / is not in your recent workspace. Example-:/var/www/html
your url should like above.
With the same problem, I did a text search and found an XML file containing the name of the project.
I had copied the project from another project. Let's say that I copied project A to project B. Although the XML file in the new project (B) was named for project B, it had an entry which still referred to project A. When I edited it, the problem went away.
Simply remove the .classpath and .project files and try.
Go to create new project. Once there, select the project type. Mine was PHP project. The new PHP project screen will popup. There, click create a new project and give the project name which you used before. Then press finish.
If you need a 100% risk-free strategy, just right click the project and select 'export', and put it back where it was. Then, you can either continue using the project in your current directory (with no more popups) or switch over to the directory you were working in before. The side effect of the former is that you will have a duplicate project taking up a small amount of space. If anything, finish up what you need to do in the current directory, then pull (via git) from the original directory. Or, delete the project in the current directory, and import from the original directory to the target directory for the second time - though now, since it is the proper way, the issue will be resolved.
I met this problem just and I just figure out the main reason cause this problem is your copying pom.xml from another already existing project in your workspace.
So the way is find the pom.xml in your project folder and rename <name>conflicted Project name</name>.
In 2021, Using Ubuntu 20 here is simple way to remove it.
In Eclipse main Menu
Window -> Preferences
In the search type recent workspaces
Select and delete the project. click apply changes
Removing a project from an Eclipse workspace does not delete the files by default. You have to check a checkbox for that. This is a Good Thing. As you have not checked the checkbox, you have to delete the files manually using e.g. a file manager.
Note that there are files starting with . in an Eclipse project directory, such as .project. They are considered hidden files on Unices.
go to the folder and delete the file .project. This worked for me.

How to import an existing directory into Eclipse?

I am on a mac, but I don't think it will make a difference. I have a directory that I want to fully import/add into Eclipse. What I did is this:
Right click import
General → Existing Projects into Workspace
Then when I click browse for either root directory or archive file and select the folder I can't click finish. The folder is empty and just contains a few folders but for some reason I can't click finish.
The Eclipse UI is a little bit confusing.
The Import -> "Existing projects into workspace" actually means import "Existing Eclipse projects into workspace". That's why you can't click on finish: the import option looks for a .project file (the file used by Eclipse to store the project options) in the directory that you have chosen.
To import existing source code that doesn't have an Eclipse project file you have the following options (I suppose that you want to create a Java project):
New project inside the workspace dir: Create a new empty Java project into the workspace (File->New->Java Project). Then right click on the source folder and choose Import...->General->File system then choose your files, and it will make a copy of your files.
Tip: you can drag&drop your files from the Finder into the src folder.
Create an eclipse project in your existing dir: Create a new Java project, but in the "New Java Project" window:
Un check the Use default location option, and choose the directory where is your non-Eclipse project.
Click Next and configure the sub-directories of your non-Eclipse project where the source files are located. And you are done :)
There is no need to create a Java project and let unnecessary Java dependencies and libraries to cling into the project. The question is regarding importing an existing directory into eclipse
Suppose the directory is present in C:/harley/mydir. What you have to do is the following:
Create a new project (Right click on Project explorer, select New -> Project; from the wizard list, select General -> Project and click next.)
Give to the project the same name of your target directory (in this case mydir)
Uncheck Use default location and give the exact location, for example C:/harley/mydir
Click on Finish
You are done. I do it this way.
These days, there's a better solution for importing an existing PHP project. The PDT plugin now has an option on the New PHP Project dialog just for this. So:
From File->New->PHP Project:
I Using below simple way to create a project
1- First in a directory that desire to make it project, create a .project file
with below contents:
<projectDescription>
<name>Project-Name</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
</buildSpec>
<natures>
</natures>
</projectDescription>
2- Now instead of "Project-Name", write your project name, maybe current directory name
3- Now save this file to directory that desire to make that directory as project with name ".project" ( for save like this, use Notepad )
4- Now go to Eclips and open project and add your files to it.
For Spring Tool Suite I do:
File -> Open projects from File System
The thing that works best for me when that happens is :
Create a new eclipse project(JAVA)
Take your source file (contents of the src folder!!!) and drag from finder and drop into the src folder in eclipse IDE
Make sure you add your external jars and stuff and tada you're done!!

How To Manually Add Project To Eclipse Without Using Eclipse

I'd like to manually create the folders/files on the file system that create a new project in a workspace in eclipse, and show up in the Project Explorer when eclipse is started and the workspace is selected.
What files would need to be created to do this and where would they need to be?
Please understand that I do not want to open eclipse and make a new project using eclipse. I want to make a new project without using eclipse.
I think you will need to do the following
create a .project file and whatever other files needed by your specific type of project (for example java projects need .classpath) in the project folder, you can find out what you need by looking at those files for another project.
In your workspace .metadata folder, this is where eclipse keeps information about the current workspace, I think the plugin responsible for project definition is .metadata/.plugins/org.eclipse.core.resources , you will need to create those files yourself, some of them are binary, so you will need to open up the source of that plugin to see exactly how it writes them. Depending on your project, you will need to write more .metadata plugin information (for maven for example).
There is no easy way of doing this. Each new project modifies many scattered files throughout the eclipse structure (if you want a list, make a new project and find files created/modified most recently, and/or search for the project name.)
Short of writing the files by hand, there's not much you can do. I found these links in my reseach, but they're both pretty old and seem to be dead ends:
http://www.eclipsezone.com/eclipse/forums/t107019.html
http://dev.eclipse.org/newslists/news.eclipse.tools/msg36546.html
Based on the answers of #shipmaster I think this will work.
Go the workspace and create a new folder as your new required project name.
Copy the contents like .project, .classpath, .includepath etc from any existing project and modify the same like project name, source folder, build folder etc in .project. Do the similar changes in .classpath etc as per the new project requirements.
Unfortunately this is not enough to create a project by just doing eclipse restart so we need to do an import project and point it to this folder and we are ready to use the same now and we see the new project created in eclipse!
try archiving the file .. right click on project ---> export --->archive file(in General section) ..after you archive it as a zip you can import it after.
IF you want to manually copy a pre-existing project to a new workspace,
I have a solution for you:
Copy the project folder.
Paste it into the new work space.
File > Import > General > Existing Project Into Workspace
Eclipse will now see the project you cut+pasted manually.
Why I am doing this:
I am doing this so I can build upon my scrum stories while keeping documentation via working files that each successive step was built upon.
E.g. Story #2 is built upon story#1 code. But I don't want to version them because I want to be able to open them up one after another to do a presentation on my work flow.

Eclipse: How to add an existing source folder?

I have a directory called c:\RemoteSrc . Under this there are 3 directories which are currently source folders (I think? the icon is an open folder with a little orange grid in it) in my Eclipse project. I have dropped a new directory under c:\RemoteSrc which I also want to add to my project.
BUT
If I right click on my project and go "Build Path..." -> "Link Source" and try to add it it tells me "Folder already exists with a different case". Yes i KNOW that the folder already exists THATS WHY IM TRYING TO ADD IT.
I think all you need to do is refresh the project. Eclipse does not automatically pick up folders (or files) dropped into it's project directory.
A screen capture might help, but if the GUI is un-cooperative, you can:
close Eclipse
open the .classpath file which defines your project (it may be located in your workspace)
see if you can define a new classpathentry of kind "src": this is not the easy method, but that may give you an idea why the GUI refuses to define the same entry.
For Linked Sources, you should have something like the following in your .classpath
<classpathentry kind="src" path="module_name"/>
With a corresponding matching entry (within <linkedResources>)in your .project
<link>
<name>module_name</name>
<type>2</type>
<location>path/to/your/module</location>
</link>
NOTE: Removing a linked project doesn't necessarily remove it from the project.
No need to close Eclipse.
Open .project file using Notepad++, find link to the existing source/folder and delete it. Save the file.
Refresh the project in Eclipse.
Now you should be able to link it again.
I had a problem where I had created a /src directory in my working directory and then wanted to link another directory with additional files to import. The "existing directory" turned out to be because the directory I was trying to link was also called "/src", even though the path was different. I guess Eclipse can't have two /src directories in the same project, similar to trying to mount two file systems at the same node. I rearranged the directories so there was only one /src, and all was well.
There were conflicts when I tried to update my project which resulted in creation of multiple .classpath files.. SO removing the copies and reverting the latest .classpath file and then refreshing/rebuilding project ,solved the issue for me.
Hope it helps!
Sometimes the simple refresh (Greg Adamski's answer) does not work, e.g. because the source folder is not in the src-directory (in my case, I had to reference Swagger auto-generated code which was located deep in the target/.... directory after a Maven Build).
In this case, right click the project, open the 'Build Path' -->'Configure Build Path' dialogue, select the 'Source' tab and select your additional source folder via the 'Add Folder' button.