Intellij deleted my project files - how to recover? - java

I was working on a project in Intellij when my laptop suddenly turned off completely(I unplugged the charger and apparently the battery loses contact if you move the computer). I'm sure I saved before unplugging. Now that I launch Intellij, I noticed several unpleasant changes:
The IDE doesn't remember recent projects; it didn't open my project straight up after I launched it as it usually did before.
Project files are all gone, all that remains is an .iml file.
The color theme changed back to white, even though I switched it to black.
Most disturbingly, local history appears to be wiped, there's nothing there save for the .iml file.
In the light of these circumstances, I have these questions:
What the hell happened? Why did all my files disappear? They were all saved, so how could they just vanish?
Is there any way to recover them or did Intellij scrapped them so thoroughly they're gone?

Right click on the project directory or folder. Go to
Local_History > Show_History
From the list of history, Right click on the change you want to recover and choose Revert

It appears that one or more of the IntelliJ project files was corrupted during the sudden power off. As a result, IntelliJ is not loading your project correctly. I would approach this by creating a new project, with the same options as your first one, and then copying the source files over from the old location.

I had no power or issues, I just left my laptop in sleep with idea running, and now everything is gone.
This issue also happened to people here: https://intellij-support.jetbrains.com/hc/en-us/community/posts/206877445-Please-help-IntelliJ-11-just-deleted-all-my-files-?page=1#community_comment_204002510
For me, I was lucky that I could still recover/undelete these files using a tool like Recuva

Related

Java files disappeared in Eclipse after exporting

I was working on a project in Eclipse that has several classes and one Interface. I decided to export it as a jar so that I can run it on another machine.
This went just fine. However, when I went back to Eclipse, it suddenly removed all of my file one by one as soon as I tried to edit one of them. Now there is only one file left and it's not even my main. I had everything in the default workspace directory and now only that one file remains.
Can I undo it?
Something similar just happened to me a while ago, Eclipse has the option to recover files no matter if you have a version control or not...
make right click in the project and make a "Restore from local history"
a new window with all accidentally removed files will appear and you can undo the mess :)

Changes to my classes in Eclipse are not reflected when I run the project

I recently wiped my disk, but I have numerous backups of all Eclipse-related files. Everything that I need seems to be here, but whenever I make changes to my classes, even after I quit and restart Eclipse, the changes aren't reflected when I run the program. The changes still have been saved in my .java files, but they don't get compiled when I run.
Things I have done:
Project > Clean (numerous times)
Project > Build Automatically is checked
I tried building manually several times to no avail
All my hot code replace options are enabled
Downloaded a fresh copy of Eclipse
Restored my old Eclipse folder from before the wipe
I should be using the same settings as before, back when everything worked, and I haven't changed any operating procedures. The project is a simple game, nothing outside the box. I checked the build path, the only things there are the old class files.
So that's my situation. Thoughts?
Not sure the reasoning behind why it happens, but a quick fix is to copy the class to a separate project, then copy it back. Fixed the issue for me.

Projects appearing twice in working sets - eclipse

I've been spending the past day trying to fix a corrupted eclipse workspace. I have it synched on dropbox and it's been working fine for a long time but recently there was a problem with some conflicting files in the .metadata folder and it messed up everything, my projects just stopped showing in my project explorer.
I ended up re-importing the projects into the workspace and they show fine in project view, but when I try to place them in working sets each project appears twice. If I delete one of the duplicates, the other one gets deleted as well. Anyone know how to resolve this issue? I'd rather not delete .metadata since that would erase all my settings and preferences.
If I were you, I'd start a fresh workspace. Use the preference export/import capabilities to ensure you retain all your favourite settings between workspaces.
I have never managed to save a corrupted workspace. Sometimes you've got to just let them go, like a rabid dog.
Check whether or not they are the same files shown twice. If this is the case then the solution is simple - go to 'Project Explorer' window, expand downward arrow to get the menu, then 'Project Presentation' -> 'Hierarchical'.

R.java not generated or updating. Deleting itself for no known reason. HELP every solution tried,

I've checked every site I can find for the last two days and read more that I could imagine it would take to fix this.
I had an app half made and then I couldn't get java to see a layout I had made. I hit clean like I had on many other things. Then R.java disappeared.
I deleted the layout just to be sure it wasn't the cause. R.java did not come back.
I then decided to rebuild from the previous project. About a quarter of the way through the same thing happens.
Now, half the time I start a new project R.java isn't there to begin with. And when it is there it doesn't update at all.
I have made sure to update to the newest software. I've tried "Build Project" I've tried restarting eclipse.
I have tried saving my R.java file and then when it auto deletes I replace it with the recent save. I get aapt.exe has experienced a problem and needs to close" which also happens when I try to clean the old projects to fix them.
This is wrecking my coding.
I often have problems with the R file as well. Here are some things you can try:
Delete R.java and see if it regenerates (make sure Auto build is turn on)
Turn off auto build and manually compile the project
Go to your hidden .android folder and delete debug_keystore, then restart Eclipse and rebuild. May need to restart the computer as well.
Completely uninstall and reinstall Eclipse
Then there's the other suggested answers... check your XML files for errors, make sure your classes import the correct R file instead of android.R, etc.
Do you get any specific error messages in the console?
This happens for ALL your projects?
On eclipse package explorer menu (left menu that your projects are listed) right click, select android tools,select fix project properties,
if it works, let everyone know so other people can benefit.
Check if you accidentally imported android.R, this can cause problems also. See answer from Lars here: Missing R.java file even though project cleaned

Eclipse does not refresh project files in package explorer view

Today I see a strange behaviour of Eclipse 3.5.2 for the first time in 3 months.
First, when I run a main function, it runs a previously compiled version. Let's say I press Ctrl+F11 in the window with an open java class and existing main function. Usually it rebuilds the class and runs a new version. Today even if there was a compile mistake, it would run fine. So I guess it does not recompile the class.
Next, more strangely, if I intentionally make a mistake in the code and Eclipse underlines those lines in red, still the project Explorer does not mark them as containing errors. They remain of grey color if there were not any errors.
First I did not know how to solve this problem. I tried to reopen the project, restart Eclipse and finally reboot the OS. After the tenth attempt, after rebooting, Eclipse said that all project's files are "OUT OF SYNC with the file system". When I pressed "Refresh" - F5 on a project's header name in Project Explorer it finally marked all the files with errors as containing errors and running the main function gave the desired result.
An hour of my work passed and this happened again , with the other project. All the same. No marking of files as red, running no matter what old version of class with no compile errors.
And since Eclipse does not tell that files are out of sync, simply pressing F5 on a project cannot help.
What can you suggest?
When you select a project in the Project Explorer view and press F5, Eclipse should traverse the entire directory tree for the project checking that all files and directories all in sync. It does for me ...
The only thing I can think of that would cause this not to work is if you have file system timestamp anomalies. For example, if a file in the file system is updated but the file's last-modified shows that it was updated in the past. This kind of thing can happen if your machine's system clock is moved backwards or forwards at an inconvenient time. If you think this might have happened, try closing all projects, restarting Eclipse and doing another F5 refresh.
(I used to run into Eclipse synchronization issues a lot, but I put that down to a combination of flakey plugins and doing builds from the command line. Either F5 or Project>Clean usually works for me.)
It is also worth checking that you haven't turned off "Build automatically"; see https://stackoverflow.com/a/2818290/139985. This is not a "refresh" problem, but it would be easy to confuse it with one.
Is Build automatically on? (Menu > Project > Build automatically)
It happened to me because there was a cyclic dependency between two projects. Each project had the other on its build path.
Solution: Reimport the project
It happened to me when checking out a new file from svn in explorer. Eclipse could not find the new file for some reason.
I tried refreshing the project(F5) and Project > Clean and build the project(Project > Build All) none of these worked for me.
So I deleted the project from the Project Explorer view(Not from hard disk). Make sure you unselect "Delete project contents on disk(cannot be undone)" checkbox and save any unsaved changes before you do this.
Now reimport the project using File > Import option. That should work in most cases.
If you use gradle, or something similar, instead of reimporting a project you can just regenerate the project files (gradle eclipse for example), and then you can refresh the project. Less cumbersome than deleting and reimporting.

Categories