Restore Deleted Files in Eclipse IDE - java

Two days ago, I deleted five Java files in Eclipse IDE and now I need them. I tried to restore them from the local history. I restored only two of them. When I right click on the other files and then click restore from local history, I get the error message No additional members found in local history. How can I restore those three files?

You can use the information in this Java Tips page (archived)
I deleted my src folder, and used the following steps to get it back:
Select Project
Right Click
Select Restore from local history in the context menu
Select your files,
Click OK.

Steps to recover the deleted files:
Go to the project.
Right click on the project.
Select restore from local history.
Select the file/files to recover.
Please see the attached image:
.

If you still have the binary form (.class), that is you only deleted the source code, then you can decompile then back to source.
Search on Google for some decompilers, for example Cavaj.

Go to Eclipse Menu Bar , and click Edit, and then click Undo Delete Resource. Each time you click "Undo Delete Resource" it brings back resources that have been deleted. I am not sure if you can recover deleted resources, if you try to recover after the machine has been restarted since you deleted your resource.
You don't wanna run into this several times, to be safe please always use version control like Git, SVN, Mercurial.

Answer: You can't.. sorry :\
If restoring from local history does not work, then you are likely out of luck i'm afraid.
my suggestion is be more careful when deleting and use a Source Control Management software like SVN or Git, so you can version your files to prevent things like this from happening again.

In case you are using VCS like SVN or GIT you can just recreate the file with same name and in the same location that's enough.

It is very simple. You can use these steps:
Right click on the project of which you want to recover.
Select restore from local history.
Select the file/files to recover plus version too.

When you see the "No additional members found in local history" message
while trying to retrieve the files after right-clicking a parent folder or package,
try right-clicking the next immediate parent folder or package in the project (or the project itself as mentioned above).
When I right-clicked the next immediate parent folder;
I was able to restore deleted files in a similar situation.

You can use the information in this Java Tips page.
I deleted my src folder, and used the following steps to get it back:
--> Select Project
--> Right Click
--> Select Restore from local history in the context menu
--> Select your files,
--> Click OK.
--> Then go to your git and do "git checkout filename"
--> This should fully restore the file and its content
I hope this helps

Related

Trouble deleting files or package in Eclipse

I'm new to Java/Eclipese. I'm following this tutorial on youtube. I'm trying just to delete some empty packages and some files that I don't need anymore. However, Eclipse is not letting me do so. I've also selected files that I want to delete --> go to Edit menu --> Delete. The Delete option is grayed out.
How to delete a file/package in Eclipse?
Thanks for helping
Just delete the root folder from your code base. Suppose your code is in C:\Mycode and you package folder start from C:\Mycode\myproject\src\com\mypackge\bla\in\etc just delete folder mypackage manually and refresh the project in eclipse.
I at least remove package like that once created.
Deleting shouldn't be a problem most of the times. I generally use the context menu by right-clicking on the resource to be deleted and select delete from it. Maybe one of the resources you selected (it sounds like you mulit-selected items) can't be deleted for some reason leading to the inactivation of the menu-item. Doing it one-by-one should give you an idea which item is the culprit.
If that doesn't help you should tell a bit more, e.g. showing the hierarchy of your actual eclipse-project where you try to delete resources from and error-messages that might show up in the process of trying to delete stuff.

My java source files cannot be commited

i am creating a small Java project and wish to put in on GitHub using eclipse.
Everything is working fine until i go to Team -> Commit, my source files aren't there.
I don't know what to do so i could commit my .java files, any ideas?
Here is a screenshot:
As you can see, there were about 4 files in the Files section, but none of them were the java files.
It is possible you skipped the "add to the index" part: you need to add files, before committing.
See Track Changes.
Click Team > Add to Index on the project node. (This menu item is named Add on older versions of Egit.)
If you don't add anything, the commit will be empty.
See also "Git Basics - Recording Changes to the Repository".

How to clean the list of previous "command line" in execute maven goal window of intellij ce

IntelliJ CE is great integrating maven execution for modules.
Im using IntelliJ CE 13, and for custom maven executions i'm using the "Execute maven goal" window.
A great feature it has is it remembers all (and i mean all) of the previous executions, which is a great thing to avoid typing over and over the same command.
BUT, if anytime you type a really long command, the window gets resized to fit in the command, so it's a little bit annoying to scroll in order to view the "choose module" button.
Is there any way of "cleaning" that list of previous executions???
To the best of my knowledge, there is not a way via the UI to clear that list. You may want to open a feature request to do such: http://youtrack.jetbrains.com/
That said, there is a hack you can do to clear it (or selective items).
Close your project
Go to the .idea directory within your project
if you are using file based project and not directory based project settings, you can search the .iws file for the following
Backup the workspace.xml file
Open the workspace.xml file
Do a search for <component name="mavenExecuteGoalHistory">
It's path is: /project/component[#name='mavenExecuteGoalHistory']
Delete any or all of the <option> elements within that <component> element
Save the file and reopen your project.
I found another solution to this problem since the I didn't get the suggested answer to work. There is a way to access a context menu where a delete option is available.
By highlighting your project folder and navigating to the top menu "Run"->"Run Maven Goal", you will be directed to the mentioned context menu.
This works on Intellij IDEA 2020.3.1
Context Menu

In intellij, How to see SVN log/history of a file renamed or moved before previous commit

In intellij, my project is under SVN control, I have renamed and moved a file then I commited it.
How can I show log/history of this file after this commit with intellij.
"renames and moves are done as a delete followed by an add" via http://tortoisesvn.net/docs/release/TortoiseSVN_en/tsvn-dug-rename.html
so this file lost its previous history.
If you know where this file was previously, right click on the directory which contains this file and in SVN context menu find something like 'show history'. It will show you all changes made in this directory, so you can find this specific file.
I find it. As the source file was rename, the subversion history will not show revisions with the old name.
To see old revisions before and after rename the file in intellij, right click subversion> compare with...
You can then compare the correct revision, with revision before rename the file.

Where to tweak an Eclipse to change the default settings used when creating a new Workspace?

We use Eclipse with projects in CVS. It has proven to be the simplest to create a new workspace when having to deal with another branch or application, and then use Team -> Import project set to get all the needed projects from CVS.
Unfortunately, I then have to do the following each and every time:
Change text font to Consolas 11 pt
Disable spell checking in text editors
Run everything in the background
plus some more of the same.
I'd like to change the standard values once and for all in the Eclipse distribution files after having unzipped the distribution (Windows). Where are these defaults located inside Eclipse?
EDIT: For now we just have a preference file which must be read in. An extra step, but works...
EDIT 2014: I've ended up creating a workspace with the settings I want, and then creating a new copy everytime I need a new one. Also handles Maven Central information etc. Accepted the oldest answer saying essentially this.
You can export your settings from a workspace and import them into any other (this basically does what VonC's answer says, but with some measure of error checking).
To do so, in the source workspace select File->Export...->General->Preferences, then select Export All and enter a file to export to, then Finish.
You can then import the preferences into any workspace by doing File->Import...->General->Preferences, browse to the preferences file and hitting Finish.
I have created a clean workspace with all settings i want to have. This workspace i have copied into a save folder i will never delete ;)
When i want to create a workspace for a new project, i copy the confugured workspace and thats it.
I have than configured the svn repository path, code format (you also can import preferences in eclipse for this), view configuration and so on.
Try checking:
<workspace>\.metadata\.plugins\org.eclipse.core.runtime\.settings
Some .prefs files could be interesting to copy from one workspace to the next.
(like org.eclipse.team.cvs.ui.prefs which contains any non-default value for CVS settings)
I want to fix the defaults inside Eclipse so the workspace is created with the defaults I want every time.
Hard core solution:
Change the .options file within <eclipse-SDK-3.5-win32>\eclipse\plugins\org.eclipse.team.cvs.core_3.3.200.I20090430-0408.jar (that is the name I have for eclipse3.5)
That is the file with the default values, at least for CVS.
Here's what I do:
Start up Eclipse
Without importing or starting any projects, edit the workspace and make all the config changes you want
Open up the workspace in windows explorer and create a copy of the folder.
Then, any time you wish to use it, copy this folder to your new workspace folder location - you may need to create the new workspace folder first (and definitely call it something different.)
This is what I do anyway. Yes, it's very dirty but it does get what I want pretty quickly!
When importing preferences (Rich Seller's approach above), especially those that were created by someone else, make sure you backup your Eclipse environment first. That's easy, since it's portable - just copy it to a temporary location.
I've totally hosed my Eclipse environment importing preferences in the past, and importing my own preferences, which I exported just prior to importing, did not fix my issues.
Fix the defaults inside Eclipse so the workspace is created with the defaults, If you want every time suggestions, then
Go to eclipse extract path -eclipse\configuration\.settings -> Edit -org.eclipse.ui.ide ->
Change value to true: SHOW_WORKSPACE_SELECTION_DIALOG=true
Similarly in this file you can directly change other default settings.
I find a way to do that:
open <eclipse>\plugins\org.eclipse.cpp.package.cpp_1.4.2.201210131-1456\plugin_customization.ini
and add
folding
org.eclipse.cdt.ui/editor_folding_enabled=true
org.eclipse.cdt.ui/editor_folding_preprocessor_enabled=true
then new project will enable folding by default.
So
You need to know where your prefer locate, in my case, folding is under org.eclipse.cdt.ui, you can try on an project then check <workspace>\.metadata\.plugins\org.eclipse.core.runtime\.settings to find it
"org.eclipse.cpp.package.cpp_1.4.2.201210131-1456" should be variable depends on what version you use. whatever it's, you should find "plugin_customization.ini "

Categories