deleted by mistake an entire package in eclipse ide - java

I have deleted by mistake an entire package in eclipse.
I tried to search in the local history as written in the :
"Restoring deleted resources from local history"
, but it is still writing that the folders don't exist !!
I have searched also in the folders of the whole project in the bin & src.

That's where Version control comes to picture.
In case if you've checked "Delete contents on disk" checkbox while you accidentally deleted the package, then I am pretty sure you'll not be able to recover it.
The situation is quite unfortunate. This can be prevented in the future by a VCS.

It is always better to use any revision control system to avoid loss of code. These situation can be avoided by reverting the local state. In this case code will get replaced by state on repository. SVN and GIT are good revision control systems.

Related

The project was not built due to "Could not delete '/Help/build/classes/exportFile'.".

When I imported my project in Eclipse Oxygen, it gave the below error.
"The project was not built due to "Could not delete '/Help/build/classes/exportFile'.". Fix the problem, then try refreshing this project and building it since it may be inconsistent"
Googled and got that to delete the contents of the bin folder and clean the project. But there's no bin folder. Tried cleaning, still the same error. What else can be done
You found a solution yourself, but here are some more informations about this error.
First, you said, your search brought up answers where deleting the bin-directory manually solves this but you don't have this directory. Reason for that is that you configured your project to write classes to the classes-directory (bin is the default).
The "cannot delete" message appears mainly on Windows systems if there is another process keeping a lock on the directory or files within. The classic reason for that is that you currently run the application or that you have an Explorer window open that shows the content of this directory. Closing the application/Explorer window normally solves the problem. Sometimes the lock keeps staying. A way to find the culprit is using Sysinternal's ProcessExplorer. It allows you to search for it by using Find->Find handle or DLL. The result can be clicked on and you can even forcefully close that entry, releasing the lock (some programs don't like that but I never had any problems doing that).
But sometimes it's actually necessary to reboot the system if you can't get rid off the lock otherwise.

Intellij - Git status shows files have been changed when they have not

I am working on a Java project in Intellij that uses git. Quite a few files are blue (to show that changes have been made), however when I right click them and click on "Git -> Compare with Latest Repository Version" it says that the contents are identical. Anyone know why this happens? It only seems to happen to files that I've opened to look at but haven't changed. Could it happen if I accidentally added extra white space and then deleted it or something? Or just extra whitespace in general?
This is how GIT is different from SVN. GIT's change detection algorithm does not depend only on the content of the file but the meta data (timestamp last modified, etc) of the file as well. So even if you are adding just one space and removing it later on; if you save it, it modifies the metadata of the file.
For more details, you can have a look at: What algorithm does git use to detect changes on your working tree?

Java File Corrupted

Yesterday, i've Closed Eclipse & then Turned Off The Computer, Now it's appear that a Crash has occured, when i started Eclipse again, Project List was empty So i've imported the Projects Again,
Problem : a Java Files is now corrupted, the file size seem correct, i can Open the File but the File is filed with "NUL" when i open it with a Text Editor & is empty when i open it in Eclipse,
I've tried to use the History Features of eclipse but there is No Any Backup in the .History Folder, only empty folders,
Is there any way to recover this Damaged .Java File ?
Thanks
if you use SVN, or other version controls, or ever back up your PC, you could look at restoring it from there. However, by your description, this doesnt seem likely.
Noting from your comments you have tried a system restore.. System restore points and backing up your PC are two different things.
Right click on your file -> Properties.
The click "Previous Versions" along the top.
It may say "There are no previous versions available", or may offer a restore choice.
Perhaps if you had previously deployed the project you can get at the class file and de-compile the class back to code but that may still result in some loss. Also just try doing a search on your machine for that file name perhaps it was backed up by you at an earlier time that you forgot about.

Eclipse SVN always includes auto generated bin dir and classes no matter what I do

I am using Eclipse Juno with Subversive plugin.
I have a java project set to compile automatically which creates a lot of bin dirs
No matter what pattern i put in window-> preferences->->team->ignored resources, eventually i see the bin dir and all of it's sub dirs in the team synchronizing perspective as new uncommitted files.
I have tried the following syntax:
*/bin,**/bin, */bin/, */bin/*
No luck.
Also, I have noticed that sometimes if I close eclipse and start it again, the ignored files disappear from the team synchronizing perspective as required, but still, some bin dirs are still present. This whole thing is very inconsistent.
Any idea ?
I have forgot to mention that I am using two worksets, one is the subset of the other, this add buggyness to the whole process appearently
Try the "Subversive SVN JDT Ingnore Extensions". It is located on the Juno Update Site, under "Collaboration". Its description says:
The feature is useful for Java development because it allows to automatically interpret output folders as ignored resources.
Seems like exactly what you want. Also, it should work independently of the name of your output folders which is an advantage if you use Maven for example (in that case, your output folders will probably be called target and not bin).
I gave up and switched to Subclipse. Now everything seems to be working fine, or at least less buggy.

Eclipse and its faux file management

I have a fairly large Eclipse project that has undergone several major refactorings over the past 6 months. Packages have been added, deleted, renamed (using Refactor >> Rename), and the same for source files within those packages.
Today I wanted to get a count of how many source files I had under the project root and was startled by what AgentRansack returned. I was expecting something on the order of 200 - 250, but it turned back ~325. I started looking at the list of files, and, sure enough, some of them were Java files I deleted eons ago.
I opened up Windows Explorer and took a gander at my project directory, and of course, saw them all just sitting there on my file system, like nothing ever happened to them.
Obviously, Eclipse is rendering a "view" (of some sort) of my project directory, and is using some kind of metadata to mark "deleted" ones, renamed ones, etc. But to the file system, nothing is changing.
Ordinarily I wouldn't be upset about this, but I just went to import a class that used to be pacakged as org.me.myproj.fizz.Widget, but was later refactored to be packaged as org.me.myproj.buzz.Widget. When I hit the shortcut (Ctrl+Shift+O), Eclipse asked me which Widget I wanted - but the first one shouldn't even exist anymore!!!
When I'm deleting packages/folders/files in Eclipse, or if I'm renaming/moving them via Refactor >> Rename/Move, how do I make sure the changes are permanent to the underlying file system??

Categories