how to recover a corrupt workspace in eclipse? - java

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 .

Related

Eclipse : Import maven project into current workspace location

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

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.

.classpath contents update in eclipse

I downloaded an eclipse project that has a .classpath which has class entries that need to be updated.
What does this do exactly?
Can I change the content of the .classpath in eclipse?
I opened User Libraries in eclipse expecting it to have the same content as .classpath, but there is nothing in it.
The contents of the .classpath file can be changed by modifying the project Java Build Path parameters.
For instance, in Package Explorer, right-click on the project and select Properties... In the Properties dialog, navigate to Java Build Path in the tree. Usually the Source and Libraries tab panels provide most of the information in the .classpath file.
.classpath file stores the classpath metadata info about the project.
There are two ways to edit it:
1. Through UI : right click project -> build path , modify here and you will see changes in .classpath
2.(not advisable) : edit .classpath file, be careful as a small error cud corrupt project.
Edit, save then build/refresh . You should see it updated in buildpath ui. If not, restart eclipse it will pick new .classpath .

Eclipse Java Missing required source folder: 'src'

I imported a jar file into workspace and this is the error I get:
Description Resource Path Location Type
Project 'Interpreter1' is missing required source folder: 'src' Interpreter1 Build path Build Path Problem
How can i get rid of this error?
Right-Click Project --> Build Path --> Configure Build Path; unselect the SRC, save, select again.
This solved my problem.
Go to the Build Path dialog (right-click project > Build Path > Configure Build Path) and make sure you have the correct source folder listed, and make sure it exists.
The source folder is the one that holds your sources, usuglaly in the form: project/src/com/yourpackage/...
Right Click Project -> New -> Folder -> Folder Name: src -> Finish
Here's what worked for me: right click the project-> source -> format
After that just drag and drop the source folder into eclipse under the project and select link.
good luck!
Edit your .classpath file. (Or via the project build path).
Right-Click Project --> Build Path --> Configure Build Path-->source-->(Select missing folder or path)-->Add Folder-->Apply-->Ok
Create the src folder in the project.
I was confused by this for hours.
Right click on project -> Build Path -> Configure Build Path -> Add Folder
One of the build path issue is it cannot find the correct /src/conf source folder. Right click on each project, Build Path > Configure Build Path. Under the Source tab, remove the folder with a red cross icon on the bottom right. It will work for the situation that there is a small red exclamation mark “!“ bedore your project name!
In eclipse, you must be careful to create a "source folder" (File->New->Source Folder). This way, it's automatically on your classpath, and, more importantly, Eclipse knows that these are compilable files. It's picky that way.
If you are facing an error with the folder, such as src/test/java or src/test/resources, just do a right click on the folder and then create a a new folder with the name being src/test/java. This should solve your problem.
I think it's because of the .classpath getting saved with the deleted source folder configuration.
Create the missing folder [ 'src' in your case] manually inside the root of the project. When I say manually, I meant outside Eclipse, using the file explorer.
Then, come back to eclipse and refresh the project. Now, the error saying it's already there will be gone.
Now, Right click on the project > Build Path > Configure Build path. It should take us to the Java build path side menu.
Make sure we are on the 'Source' tab. Delete the source folder causing the problem. Now, maybe the folder might show up in the project structure and you may delete that too.
Eclipse wouldn't let me point to an existing (or add a new) source directory.
Eclipse's configuration files can be wonky. In my case I should have started simple. Right click the project and click Refresh.
In my case eclipse reported this in the Problems view on the parent project which does not have any code. I just delete the error whenever it is reported on this parent project where src folder is really not needed.

Categories