-1

I was making a jar file but accidentally wrote TimerV1.java instead of TimerV1.jar and as a result, my whole source code got replaced with machine code and the sad thing is there's still something I have to edit.

I am using Notepad++ and tried searching the Roaming directory but there's nothing there.

I also tried decompiling the jar file and editing the exported source files (with JD-GUI) but when I try to compile those source files I get errors that I don't even know how to resolve.

Is there any way to recover the previous versions of my java file?

WBAR
  • 4,924
  • 7
  • 47
  • 81
  • 10
    Good time to start using git – Alex Salauyou Aug 27 '15 at 13:27
  • 1
    @SashaSalauyou presumably it is just _after_ a good time to start using git – khelwood Aug 27 '15 at 13:33
  • Do you have automatic regular backups set? If not, then you now know why you should. If you have, then recover the latest version from the backup disc/folder/whatever. It probably won't be completely up to date, but it will give you a head start. – rossum Aug 27 '15 at 13:39
  • You may want to try a different decompiler. I have had good luck with this one - https://bitbucket.org/mstrobel/procyon/wiki/Java%20Decompiler, there are also links to some other alternatives. But as with the above comments, version control is your friend even for personal projects. – user3745362 Aug 27 '15 at 13:42
  • @rossum Unfortunately none. I just learned my lesson. – Friency Fernandez Aug 27 '15 at 13:45
  • @SashaSalauyou to be really honest, I have no idea how to use git. – Friency Fernandez Aug 27 '15 at 13:48

4 Answers4

2

You can use JAD (Java Decompiler) but.. not all code can be reversed into source.

Try one of:

WBAR
  • 4,924
  • 7
  • 47
  • 81
0

I don't use Notepad++ myself but it seems there is a backup folder where older versions of edited files are kept:

C:\Users\<user>\AppData\Roaming\Notepad++\backup
Pierre
  • 51
  • 1
  • 6
0

There are various utilities out there that can recover deleted files, I think because typically they are still there but the OS lists that space as unallocated. But overwritten files...I wish I had a better answer but I don't know if they can be recovered, unless some version was saved somewhere.

If it was a relatively short file, maybe the best thing to do is take this as an painful opportunity to use a backup service like Carbonite or Dropbox, and use version control like Git or SVN.

Paul J Abernathy
  • 993
  • 2
  • 12
  • 25
0

Nevermind. I have used another decompiler and debugged one by one. Thanks to those who answered :) I used Cavaj Decompiler.