I accidentally deleted my code... What can I do?


While deleting some unnecessary assets within my project, I accidentally selected several of my source files and have accidentally deleted them.

As I do not have a back-up, is there any way for me to be able to find the file?

So far I have tried:

  1. Looking in the recycle bin. File is not there.
  2. Going to the source folder of the project in file exporer. File is not there.
  3. Re-creating files with the same names in jMonkey. In more user-friendly browsers like Eclipse, this would restore a deleted file. In JME, seems not.

I cannot find any information on the issue anywhere, and any help would be appreciated.


P.S. I know I was an idiot for not backing up - It was only a 2-week-old project and I had not yet considered it important enough.

Google for any un-deleting disk tool. Try to avoid any saving operations on partition where your project was, install the program on other partition.
You can try to decompile your .jar file, if you have one. This way you can restore about 90% of our original code.

1 Like

Then… once you’ve recovered what you can and have moved on… install a version control system and setup a local repository. 5-10 minutes now will save you lifetimes of trouble.


Make sure to use your HDD as little as possible, until you have recovered your missing files, the data is most likely still on the disk, but marked to be overwritten (which could happen by any process writing to the disk, at any time). I’ve gone through a similar situation managed to recover 99% of my files.

run around and scream :smiley: and next time use version control


Do not use the installed system if possible.
If you have an external disk with enough space, boot from some linux livecd and do a full backup of the disk, then you can proceed to recover without further dangering your files.

dd if=/dev/sdXY of/dev/sdZ1/mybackup.img

X-Y being the mains system drive and partiton number (if mounted via some filebrowser visible with df in terminal
Z being your usb device.

Carefull here, dd is a low level utility that just copies raw bytes, if you mix up your numbers or whatever it will happily copy anyway destroing much data.

1 Like

Did Ctrl+Z not work? And does the IDE keep a local change history by any chance?

I’ve never used Git before, and unlike Eclipse, I can’t find any simple way to set up Git for JME3. Is there a tutorial anywhere on how to set it up for JME?

Unfortunately, the only JAR file I had was old - As I said, it was only a two-week-old project, and It was only in the past 2 days that I added water, lighting, terrain, shadows, and other important items.

I tried to use a file recovery tool, but the file is either overwritten or already too corrupt to be recognized. I’m not going to hold my breath on getting it back any time soon.

And no, Control+Z doesn’t work. I tried that too.

At the moment, I will just have to consider the files lost forever and just try and re-code everything I’ve done.

If you are on mac or windows I might suggest sourcetree, while being abit slow, it is very comfortable.

Then you may want to pick something simpler like SVN… which works with the SDK. (Though GIT should also it’s way more complicated.)

SVN is as simple as version control gets. No need to worry about branches or any of that garbage. Make a change… commit the change.

GIT is more complicated. Every operation beats you over the head with branches. Else it can be used similarly except you have to do what I call “committing twice” where you say you want to commit something and then you commit it.

If you are unfamiliar with version control then SVN is probably the easiest place to start.

The SDK works with git, I guess even automatically (When it has found a repo), if not it’s available as a plugin.

The only thing that I see as complicated is creating a repo (that is, setting up permissions and ssh on a linux box).

Do you want your project to be open source? You could go to github and create one there, they have pretty explaining tutorials but you can’t have private repos. bitbucket has them but personally I created one on my home server.

Other than that, if you are only one user and one computer, you shouldn’t have to think about branches or anything, just commit your changes. Or revert your working copy to those changes.

As others said, SourceTree visualizes everything so you can really easily work on it.

This could be another alternative Seafile - Open Source File Sync and Share Software .
It’s not as powerful as git or svn but it’s a lot easier and it still keep the history of the changes. It resembles dropbox for features.

You don’t need to do this for GIT or SVN. Just create a local file-based repo. Done. After all, especially with git, every clone’s repository is basically a local file-based repo. For SVN, svn init the directory you want to store stuff to then svn co the directory where you want to do the work.

Yeah just do this and job done :smiley:

git init

But in all honesty, start using git now. Even if feels like it’s not the right thing for keeping track of your code, which I suspect it’s perfect for. You should at least learn git based on the fact that it’s become or becoming the standard choice of version control for most developers and businesses out there. Learn it, it will be good for you and your CV either way.

This might be too late (?) by now, but if you right click the package where you deleted the file(s), select “History” and you might find a “Revert deleted” option there. (Yes, I’ve done this too, once).

1 Like

If you use only 1 computer, it might not be that useful, but I have been using SourceTree and Bit Bucket for a while now and it works like a charm. Its git, It’s free, the interface is pretty clean and… well what else can a man ask for? xD

O and it as an Eclipse plugin that work kinda good, just don’t pass him some weird file format without explaining him that he should not make a comparison, or it will give you unsolvable conflict that require some git --brutal force

Dang, but I decided to be an idiot and overwrote it with a class of the same name while trying to fix it.

Especially as that lists other java files I’ve deleted on purpose.

At least I know for future, but I wish someone’d told me that earlier.

after that just Team->commit in your jme IDE its that simple really. and tons of help out in the internet if you manage to screwup something.
From time to time do a git pull; git push to have it save in dropbox (or any other location). I love git actually. offline commit when I work in the train for example.

And to clone it to any other computer with this dropbox setup? just do git clone $HOME/path/to/dropbox/path/to/gitrepos/yourprojectname