Trouble deleting files or package in Eclipse - java

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.

Related

How can I clean up my eclipse project after deleting a .java whose .class file still seems to be somewhere?

So, I deleted a couple of .java files from within eclipse because I didn't need them anymore. However for some reason another class still uses them and compiles without a problem. When I go to the declaration of the constructor of one of the deleted classes a .class file opens of that class even though I thought they got deleted by eclipse when I deleted their .java files.
I have tried to clean the project and I tried to find the .class file using the system file explorer in the folders that are listed in
project > properties > resource > linked resources. However I couldn't find them.
Now, since I deleted those files/classes there should be a compile time error wherever they are used but everything compiles without an error, even using the code that should've gotten deleted. A colleague that recently joined the project does receive compile time errors, since he doesn't have those class files. And I want to get them too, so I can fix the code where the classes were used. Of course he could show me the lines of code that are affected but if this happens again he would probably be affected as well as he would have the class files by then.
Try doing the following
Go to project > properties > Java Build path >Source
under that you can find Default Output Folder section, simply delete the classes folder under that location with in your project.
Try cleaning the project.
Or
Simply close the eclipse and reopen it again, sometime this would work for me.
Hope it resolves your problem
If you just deleted the sources, they binaries would still be there. So open the Navigator View and go to the project in question. Look for the bin directory and delete the appropriate class files. Otherwise, delete the project itself.
You should also ensure that no other programs depend on those class files.
I found the problem. Someone built a .jar file I didn't know of which contained a lot of old code.
I found it by right clicking the constructor and selecting
references>project

Eclipse : how to link and merge two linked ressources in the same project?

I have two projects, both have the folder "rsc" which contains all the ressource used.
what i want to do is access the ressources of the first project from the second project, i am not allowed to change any code, so i can't change the folder's name, it should stay "rsc".
how do i link the "rsc" folder of the first project to the second project, how can i tell eclipse to merger the two of them, any ideas on how should i do it?
because obviously it is impossible to add the same folder (name) twice.
and thanks in advance!
Edit:
the objective is : tell eclipse to get the ressources from the first project, then if none by that URI was found, go to the second (current) project.

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".

R.java gives an error

My R.java gives an error
public static final int 1405308882_more = 0x7f020000
Don't know or understand why its giving this error, i regenerate the R.java file and it still gives me the following above. and when i hover my mouse over it, it says
underscore have to be located within digits
I tried editing it but when it compiles it still regenerate the same name variable.
Please before anyone starts rating this question as usless take your time to understand it
I don't have error in any of my java files either in the src folder or layout folder every thing else is fine its just the R.java that generates that constant so please understand before you jump to conclusions. Thank you.
There might be some thing error in your res folder once check each and every file and clean your project once and refresh it again..
Sounds like the R.java file has not updated, try some of these general pointers to begin with:
Do not manually edit any of the files in the gen folder, as these are automatically built for you.
If you find it is out of sync then try refreshing the project.
If that did not work try a clean (project -> clean)
If that did not work delete the gen folder, from within Eclipse, (do not panic) it will then be rebuilt by Eclipse - however if there is a coding error of some sort it may not do this straight away.
Hope this helps..
It wasn't the XML file that was the issue. It was an image in the resource folder with a name that didn't follow the standard naming rules and thus made the R.java to generate that error.
The reason it regenerates same is because it regenerates from your code you should check the .xml files of this project the problem is probably at 1 of them try clearing xmls you have created then regenerate it.

Restore Deleted Files in Eclipse IDE

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

Categories