3

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?

durron597
  • 31,968
  • 17
  • 99
  • 158
Michael Rentmeister
  • 167
  • 1
  • 6
  • 24
  • 1
    I think there's a lesson here about keeping proper backups... – Freddie Aug 01 '11 at 16:14
  • 8
    On top of the answers below, I would strongly suggest you look into a source code repository. This is one of the benefits they offer. There are even some pretty good free ones out there. – rfeak Aug 01 '11 at 16:15
  • possible duplicate of [How to decompile a whole Jar file?](http://stackoverflow.com/questions/647116/how-to-decompile-a-whole-jar-file) – Jonas Aug 01 '11 at 16:15
  • Todays lession: Version control! – Thorbjørn Ravn Andersen Aug 01 '11 at 16:26
  • Just a tip for future projects. Try using something like Bitbucket to easily backup all you code etc. (Google for more info about it) – Pangolin Aug 01 '11 at 16:36

2 Answers2

9

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

tskuzzy
  • 35,812
  • 14
  • 73
  • 140
  • but if it wasn't on my computer, but on my flash drive, would the recovery tools get it back? – Michael Rentmeister Aug 01 '11 at 16:17
  • I think most tools will also work for flash drives. You usually just have to choose which drive(s) you want to search for deleted files on and it'll do a full scan. – tskuzzy Aug 01 '11 at 16:18
0

You can use a decompiler ( see How to decompile a whole Jar file? ) but you won't be getting "original" source back.

Community
  • 1
  • 1
digitaljoel
  • 26,265
  • 15
  • 89
  • 115