Eclipse and its faux file management - java

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??

Related

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 Luna takes a long time saving an xml file :(

About a month ago I went from Windows to a MacBook Pro.
Same Eclipse version, (almost) same settings, but it frustrates me that saving an xml file takes about 10s :(... Even if I just delete/add a space char.
I have a lot of files, about 10 projects opens in Eclipse but my old Windows box with an old quad core (not even an i7) had no problems with this.
I know this is a knows problem in Eclipse and I had it in the past as well, but it was solved after a few upgrades in the past.
Currently I run on the latests Luna version, with up2date plugins, tried a lot of possible solution, most from SO, but still not solved. Please some help.
I am using EE Eclipse to mainly develop java web apps and use the following plugins: AspectJ (with Xref), EGit, JGit, CheckStyle, Maven, TestNG.
All files are stored as UTF-8
Editing the xml file is slow in both the text and the xml editor.
It concerns xml files that are located in a java package (in the /src/main/java/ folder).
The strange thing is that Editing an xml file in a project-root subfolder isn't slow, like: project-root/test-output/bla.xml (works well in both the text and xml editor)... weird...
Both files (the slow and fast save one) are part of version control and used by Git.
In case I copy the slow file to the folder project-root/test-output/, it's also saved fast :(
Renaming the slow file such that it has the "txt" extension and editing with the text editor has not effect.
I thought it is caused by some builder that works only on the java source folder...
The project has a Java and Maven builder. Disabling them has no effect.
The Eclipse log file doesn't contain any relevant exception. It contains some key-binding exceptions and resource tree locked modifications, but these exceptions are old.
What I tried (what I can remember):
+ Disabled all validation (especially the xml validation), for all projects.
+ Ensure all latest updates are installed of all plugins, including the EGit plugin.
+ Disabled Checkstyle.
+ ...
Any ideas as I am getting a bit frustrated about this?
A poor-man's solution may be in
switch to a empty workspace (workspace2 in example)
create a new pde-plugin-project (mytestplugin in example)
debug the mytestplugin means you debug a instance of eclipse too, so use the workspace you usually work with in the debugging-second-eclipse.
Now: save the xml-file in the debugging-second-eclipse with the workspace you usually work with, quick jump to the first eclipse and press "pause" to stop the second-eclipse.
inspect the compleate debug-stacktrace-thread-tree in the debug view (please post the image as a comment here).
Regards
When Trying the solution of #Peter I noticed that the workspace I was using was located in the "eclipse.app" file like this:
/Applications/eclipse/Eclipse.app/Contents/MacOS/D:\Users\Ed\Develop\Projecten\EclipseWorkSpace/
No idea why/how this happened. However, I moved this workspace to a "normal" directory in my home folder, and how saving an xml file work normal, fast as expected...
No idea why having the workspace located in the eclipse.app made it slow, but it works ...
Open eclipse.ini.
Increase -Xms, -Xmx
This works for me.

Lost resources after importing project in Eclipse

I've been writing my java in a text-editor, compiling and running my code with a batch-file. I'd put all my resources (.png-files) in the bin-folder for my classes to read.
this is the structure of the map.
MyProject
bin
src
batch-file
After 8 months of coding in Notepad, I finally decided to give an IDE a chance and went with Eclipse. I created a project called MyProject, having understood that was the way to import existing source code. Next thing I know, my .png files doesn't exist anywhere on my computer (I can't find them with Windows search function) I am very upset and angry and regret having deployed Eclipse at all. Can someone PLEASE give me good news and tell me how to get those lost resources back?
No good news my friend...if you decided to do that big jump you should read something about how eclipse (or another ide) organizes projects....specifically the result of incremental compiler (classes) are written (by defaults) in a directory called... bin!.. probably that's the reason why you're not finding your files...you lost them
.

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.

Executable jar file won't run after doing some updates

I am working on Java project (A terraria like sandbox game) and I have come across something that I just don't understand. I have been exporting the project as .jar's as I go along to upload and share with my friends, but the last time I did this, the .jar won't run, but when I run it in eclipse, it runs fine. When I try to run the jar all it does is lose focus on the explorer window for a split second, then goes back. I have tried many things, like changing the main class, changing the META, and moving the files to specific packages, but nothing is working.
The project is 9 classes, so I won't paste all the code for it here, but the latest, non-working source code can be found here (http://www.mediafire.com/?fiw6wq73j7cff4t), the non-working jar here (http://www.mediafire.com/?bhjo162oh3hi2j9), and the working jar here (http://www.mediafire.com/?h918s8xpyxw4psr). If someone with more experience in java could please take a look at this it would be much appreciated.
One of the things I tried was not adding the JPanel (the game), and just leaving the splash screen, and the jar worked. This shows that it must be a problem in the coding somewhere.
Thanks for the time,
I.D.
Couldn't find message comes from your ReadMap class. So check which circumstance leads to this error. Most likely you did not add all classes or other files to your JAR, so file is not found. Check that all needed files are added to exported JAR in Eclipse export dialog. It's also a good idea to provide more debugging info (stacktrace is ok), especially when you are studying. BTW, cool game :)

Categories