Eclipse : Import maven project into current workspace location - java

Would you guys, please tell me how to import the existing maven project which we have copied from different user into my local and wanted to imported into new workspace not just project view vis but the content of project classes and pom.xml need to copy physically into my new workspace directory.
Means, if my current workspace location is : C:\ALL-PROJECTS\New-Project\ and my copied location of that project isC:\Downloads\Copied_Project\ so, i wanted to copy all code from copied loc : Copied_Project to my current workspace location : New-Project
So that in future i will going to keep one copy of it, going to delete copied location. And that will be more manageable in future onces we have many projects like this.

File > Import > General > Existing Projects into Workspace
Click Next
Select root directory of project
Check project in Projects lists and check option Copy projects into workspace
Click Finish

Just copy that project to ur project location and import that from same location

You can import as usual but you have to leave all the meta data like .classpath and .project etc files because you changed the location of your project so these files having the physical location path which is already changed by you. So it will not work.
Else you just searched the old location inside all the files and replace with location and import into eclipse or IDE.

Your best bet for copying projects between different Eclipse workspaces is to export the project as a jar file
You can then take that exported project .jar file and import it into your new workspace using the Import Existing Projects into Workspace and selecting your archive (.jar) file

I don't know about other IDE But in eclipse this is how it is done
copy the project folder into your workspace folder
Make sure the project folder has pom.xml immediately under it .
open eclipse . your copied project will not be found unless you import it .
So Go to
File->import->Maven->Existing maven project
Then choose your project folder from explorer and follow the procedure your IDE takes you through
Finally right click on the project Go to maven->update project

Related

How to add project of different workspace into the current workspace in Eclipse

I have two workspaces and I want to use java file as a parent class or you can say extends it from workspace2 to workspace 1 in eclipse, how can I do this?
As I can add project from same workspace but unable to figure out from different workspace.
I dont want to import the project.
Thanks in advance
You can make New File -> advanced options and Link to Folder in the system where the class is
You need to import your project from workspace 2 to workspace 1.
You can reference your project in another workspace in the build path configuration of your project, linking two eclipse project, even if they are in different workspaces.
If you want the code to be available for changes this are your options:
You have to either import the project or create a new workspace that includes them all.
Note that you may extend the java class from the same project or from another project within the workspace, but not from another workspace.
If you are willing not to have the code in front of you available for changes, you may build the first workspace' project into a jar and then use that as part of your other workspace.
Way 1
You can add the second project's src folder to the current project and you can add them in your project.
Right click on project -> Build path - > source tab - > link source
Way 2 :
Make that external project as a jar and add as a dependency.

How to import a spring project in STS

Just by a mistake I had deleted a spring project in STS.To use it back I borrowed the same project from my friend in zip format but when I tried to import it says
Some projects cannot be imported because they already exist in the workspace
Following is the way I tried to import
file->import->general->existing projects into worspace->select archive file
and after browse when I select the zip project
Some projects cannot be imported because they already exist in the workspace
and the finish button and next button are in disabled state.Please help me
The workspace in STS/Eclipse is not automatically the same as the file structure that you have on disc in your workspace directory. You can have projects in this workspace folder or somewhere else on disc.
To get them into your project explorer (and access them from inside STS/Eclipse), you need to import them (Import Existing Projects into Workspace). Then you can select the folder where those projects are located in. In case you have those projects already in your workspace folder on disc, you can choose the workspace folder as root folder in the wizard. It will show all the projects that exist on disc in that folder and grey those out that are already imported/referenced in your workspace in Eclipse.
Make sure it is really not in workspace, also if there aren't any other projects with the same name. If not, just delete the .metadata folder or create a new workspace.
Check if you still have the project in folder of the workspace on disk. You may have deleted in STS, without checking 'Delete on disk'. So, the project may be still there in the workspace folder though its deleted in STS.
I get this issue from time to time. Usually I just open a new workspace but sounds like you don't want to loose other projects.
I simply open the.project file in my project and change the name of the project in name tag.
Good Luck!
Probably whey you 'accidentally deleted' your project, you only deleted it from the Eclipse workspace, but not from the actual workspace folder on your hard-drive (as other people pointed out, Eclipse can arbitrarily map workspace projects to files on disk, so it is possible for a project to be 'deleted' from your Eclipse workspace but still exist on disk.
The good news is the files you deleted are actually still there.
Instead of importing your project from a zip, you may just want to import those files from the workspace folder back into your Eclipse workspace.
Generally this kind of problems not occurred you can go to Project option and clean and than restart STS.
May be STS is not synched with the latest configured project.
When you launch Spring Tools Suite, it will ask you to Select directory as workspace as below:
If the directory you selected here (i.e., workspace directory) is the same as the directory where the project that you are going to import resides, then you will get Some projects cannot be imported because they already exist in the workspace.
Therefore, to solve the issue,
Close Spring Tool Suite
Create a new directory
Launch Spring Tool Suite again
And, select that as your workspace
Launch the application and you would be able to import as you mentioned in your question
It solved my problem.
Hope it helps..
Happy Coding!!
the problem is that when you delete a project maybe sts only close it.
Try View Menu --> uncheck closed projects
Now you will see all closed project, simply delete it.

Eclipse doesn't show projects in package explorer

I keep my workspace folder in the Dropbox folder so I can use it on different computers. Usually there isn't a problem. Today however I opened Eclipse and found it doesn't show the projects in the package explorer.
I checked and it's set to the correct workspace folder.
I tried to Import existing projects into workspace, but Eclipse doesn't allow importing the projects because 'they already exist in the workspace' - even though they don't appear.
Will appreciate your help.
Keep your project files in DropBox. You shouldn't share a workspace like that -- it will inevitably lead to issues like the one you describe.
That is, keep the project folder, along with the .project, .classpath, and .settings/ in your shared Dropbox space. Create a new workspace on each computer, then "Import existing project" into each workspace, selecting your project in Dropbox, being sure to unselect "copy projects into workspace".
I don't have idea about using dropBox-BUT-However
For your question::
I tried to Import existing projects into workspace, but Eclipse doesn't allow importing the projects because 'they already exist in the workspace' - even though they don't appear.
Possibility:: Projects are not in Eclipse explorer but a copy of it exists in the workspace folder so eclipse is not allowing you to add the projects with same name again.
Solution:: Create a new workspace and then use dropbox to import the projects.
What you can also try is do
Create new General Project
Select in current workspace
Create project with name of an already existing project in your workspace
I seem to remember using this to "hydrate" already existing projects in my workspace into the eclipse package explorer.
This happened to me and it was because I inadvertently filtered out some of the files in the filters option in the Package Explorer.
Inside PackageExplorer -> Small drop down on top right side -> Filters
Un-select all and see if your files are now visible. Worked for me.

Can you import a non-archive project directory in Eclipse?

I read this article which shows how to import/export projects in Eclipse (although it seems a little outdated and I'm using 3.7 Indigo).
To export a project, you go to File >> Export and it creates some kind of "project archive" file on the local file system. You could then email it to someone else, who could then import the archive as a new project or into an existing project.
But what if you don't have an "archive" file to begin with?!? What if you just have the project files and directories but without all the Eclipse-metatdata (.project file, etc.)? Is there anyway to tell Eclipse to look at, say:
/home/myuser/some/path/to/project/root/
src/main/java
SomeObject.java
build.xml
...and get it to read that as a new Java project?
Try the steps below:
Create a Java Project in Eclipse as below:
Load the project contents from your file system as below:
Hope this works for you.
.project and .classpath files are the base of the project structure. Without a .project file Eclipse won't recognize your project. The .classpath is important too but that one changes between environments. Should you use the files from another environment you'll have to reconfigure some settings.
Rather than emailing code, I suggest you use a Version Control system and, also, some Eclipse plugins. SVN + Subclipse for example.
If you trully want to send the project to another person just send him the project's folder and import it as an existing project by doing right click on the project explorer and selecting Import > Existing Project into workspace.

how to recover a corrupt workspace in eclipse?

I had a corrupt workspace (due to svn collision).
I deleted the .metadata directory from the workspace, and then reloaded eclipse, and did an "import" of a project into the workspace.
However, the project got imported in a rather strange way -- all directories in the project appear, but the src/ directory does not have automatic compilation (when choosing a .java file) -- it is as if the src/ directory is not identified as a special directory.
Is there a way to fix that?
I also followed http://letsgetdugg.com/2009/04/19/recovering-a-corrupt-eclipse-workspace/, and that did not help either.
Switch to a new workspace.
Then go File -> Import -> Exsisting projects into workspace .
In the root folder text box , type the address of corrupted workspace.
Click Refresh .
Select the projects and click finish
All configuration data for your workspace is stored in .metadata. Try to recover the deleted folder then fix the workspace. Otherwise you will need to reconfigure everything.
You can salvage certain folders from .metadata to keep your preferences (e.g. key bindings) at least.
After importing your project, check your project properties, especially the entries in "Java Build Path". There you have to add the "src" directory as source folder. Maybe you also have to adjust the output folder and libraries you are using in your project.
create a new project.
copy your pages ,library files,etc.
set build paths.
compile it. then others will be automatically created
copy project to another (right click -> copy in eclipse)
new project created was correct for me in same situation and .class files repair .

Categories