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?

5
  • 1
    I think there's a lesson here about keeping proper backups...
    – Freddie
    Aug 1, 2011 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 1, 2011 at 16:15
  • possible duplicate of How to decompile a whole Jar file?
    – Jonas
    Aug 1, 2011 at 16:15
  • Todays lession: Version control! Aug 1, 2011 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 1, 2011 at 16:36

2 Answers 2

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

2
  • but if it wasn't on my computer, but on my flash drive, would the recovery tools get it back? Aug 1, 2011 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 1, 2011 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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.