Recover corrupted java file - java

I tried to reimport my android project on eclipse to solve a problem but I accidently overwrote all my files in the project. All of them had been corrupted which means their size is now 0B...
I tried to use Local History but it's useless since my project is no longer in my workspace, same for .metadata.
I also tried to use Recuva (Software for recovering files) which see my files with their real size but when I try recover them, their size is always 0B...
I lost about 7 days of work and I don't really want to rewrite my code using Java Decompiler...
So my question is, is there any solution to recover that files ?

I wrote 200 lines of code and suddenly system restarted. I lost all code. But I recovered data from eclipse's local history. Right click on the file -->replace with-->previous from Local History

Eclipse has a local history, although by default it's set very low - one of my first tasks when setting up a new development machine is to up the values (in addition to my other version control)
If you do have a history you can right click on your class, and select compare with local history.

You could try decompiling with something like JD-GUI. It might not be as onerous as you think. Obfuscators exist for a reason.

It is not really programming question, but i had similar situation and "Mini Tool Power Data Recovery" tool helped me (it is paid tool, free version exists, but maybe you can search in this direction and find something open source). I tried some another tools then, but with no results.

Related

Is there a way that I can get back my accidently deleted code in eclipse?

A couple of days ago, I was copying and pasting my code into a new class. While the entire code was selected, I hit the backspace key. The entire code deleted, and I did not realize. My computer then died. Today, I opened it back up, and none of the code was there. The only thing that remained was an empty file. Is there anything I can do?
The two comments cover most of it. There are only 3 places your code could possibly be. If you checked them all and none of them have it, you're out of luck.
Eclipse Local History
Right click the file in the package explorer and pick the 'Restore from local history...' option. Hurry up, eclipse auto-removes local history that's older than 7 days!
VCS
If you're using version control and you checked this in before, it's a simple restore away. For example, git checkout path/to/the/file.java would do it. You'd have to explain which VCS system you are using and how are you accessing it (via eclipse teams, via e.g. Fork.app, via the command line, etc).
Backups
You're using a computer. It should have backups. These backups need to run automatically and preferably be going 'off site' (to a place that you do not live, you don't want a fire or some serious burglary to mean you have lost both your system and your backup!). If you don't have that, you're, uh, well, I don't want to insult you, so you should find some suitable insult that describes a very silly person and then yell that at a mirror.
The only excuse to not have backups for a system is if the system does everything in the cloud. Chromebooks really don't need it for example. If you're programming, unless it's some fancy cloud-based programming layout, this does not apply to you, and therefore you should be finding a mirror right about now if you don't have a backup solution in place.
There are open source tools like arq where you fully control where the data goes. Various NAS (Network-Attached-Storage) systems have the option to sync with another NAS elsewhere over the network, so buy one for yourself and for a friend, and be each other's backup buddy. Or just toss some money at it; services like Backblaze offer fixed fee backups and offer client side encryption if that's a worry for you.

(Bad) lagg on auto complete in Eclipse

Basically when I auto complete on Eclipse (By pressing CTRL+Space) the program laggs for about 5 seconds. This is getting really annoying because I use the auto complete alot. How do I fix this?
The workspace I'm working on is located on a NAS with a 1Gbit/s connection. Could this be causing it?
Thanks.
Check if problem exists with local resources too
Create a local workspace and open it with same eclipse instance. Now create a simple java project by new project wizard at your local machine inside this workapce and try code completion there. If it's still slow go to Step 2.
(by the way - I wouldn't store workspace information on remote side, but always local)
Check proposal kinds
If it's not a network issue and the problem still exists on a simple local workplace with local sources you should inspect your proposal setup as shown in next picture.Maybe one of the proposal kinds is slowing down your IDE. You can experiment with turning off proposal kinds sequential to find the problematic one.
System requirements
If you got stil the problem after doing Step 1-2 maybe your system has not enough power/memory to provide eclipse (but normally not the reason - I am using eclipse at Linux on an old T61 notebook with 4 GB Ram + SSD and it works fine!)

Linux Version of Eclipse is freezing when trying to open binary files (with .bin extension)

I had tried opening binary files of size 32MB. Eclipse (in Linux version) is freezing and I'm unable to perform any other operations (because of this hang in the Eclipse product).
I'm not even able to run other processes (like Task manger to exit the Eclipse IDE) which forces me to re-boot the system.
It seems that there is a problem in a particular plugin that you are using in your product, and that it is affecting your users.
If the plugin developer isn't helping you, your options are limited:
You could "bug him" about it ... but this probably won't help.
You could offer him (or someone else) money to fix the problem.
You could try to find and fix the problem for yourself (assuming that the plugin is open source).
You could identify an alternative plugin with the functionality you require.
You could implement a replacement plugin yourself ... or pay someone else to do it.
From the technical perspective, I doubt that we can help you unless you explain in depth what the nature of the problem is, and what you have found. On the face of it, it sounds like a scalability issue; i.e. the plugin is using an SWT widget that does not work with huge files. If that is what the problem is, then the technical solution is probably to use the widget in a different way ... that avoids the issue.
Opening 30Mb binary files in an editor is kind of pathological.

How does a proper UpdateLauncher for java look like?

I was working on an update launcher for a java .jar application. I have several .jar-archives and a main.jar. My launcher adds/replaces the necessary jars when updating.
I am just not sure what criterias to look after. So I'll describe how the process works and you might tell me if I forgot something.
Load and compare version.xml file from ftp update server
Make a list of updated items with the help of both version.xml files
Check (to be sure) if those files which are still valid really do exist on hard drive (either add them to the list of items that needs to be downloaded...shouldn't happen anyway)
Create a list of files that needs to be downloaded (those items are on the server in a compressed form)
Download all needed files to /temp folder
Unpack all files to /temp/unpack
Move all unpacked files to /data folder (or where they belong to)
Update local version.xml
Check if all files match the actual version-file-list
I am really not sure if I forgot something? If some users mess around with files in /data my updater recognizes this and proposes a "repair-update" where all missing files are beeing redownloaded. But what about users messing around with version.xml? I should store that encrypted. Is it necessary to keep the downloaded version.xml from update server open so that noone can change while checking version and updating? Or am I worried too much about all that?
Does all this work out so far and is it secure enough to not creaty messy installations on a users pc after patch?
Do you intend to use the System Tray class from Java 1.6 to notify the user of the update? To me, it seems like something like this would involve implementing an OSGi updater (sorta like how Eclipse project does it in the IDE). Also, the JVisualVM.exe tool (that comes with JDK) is an excellent example of this sort of thing and maybe you could get ideas from that although I suspect its coded in C++.

Can jar files be decompiled to get original source?

I have a major problem that happened to me. I am writing a program that has taken me 3 months+ to make and today I accidentally deleted the source code.
I am working in NetBeans and I had just cleaned and built it, so I still have the working .jar file. The program was saved on a flash drive, not my computer, so the classes are not in the recycling bin.
Can anyone tell me about how I can go about getting my source code back?
Unless you explicitly packaged your source code in the JAR file, there's no way to get back the original source. You could try using a decompiler (like this) but that will hardly give you nice, readable code.
The best solution would be to stop using your computer right now. Then use a recovery tool to recover your deleted files. The more recently it was deleted, the higher the chance you'll get it back. There are lots of tools that can be used to do this (just Google it).
You can use a decompiler ( see How to decompile a whole Jar file? ) but you won't be getting "original" source back.

Categories