As the title says, I saved over my code. I am screwed because I really need the old version.

I have the original compiled .class file... can i some how get the code from inside there? or recover an earlier version of this java file (which is/was stored on my thumb drive)?

Recommended Answers

All 6 Replies

You have now found out the hard way why a good version/source control system is one of the keys to productive programming. Even a mediocre one is better than nothing. Please spend an hour or five reading up on git, mercurial and svn. Here's a starting place. The Wikipedia article is good too; and here is a discussion of pros and cons which is a little bit dated.

Here's a very dated article about Java decompilers. I presume there are modern ones available. In my humble opinion, you are better of using your memory of what was in the file to recreate it in an editor. Probably.

I do use IntelliJ IDEA that once you right click on the file you can find Local History option in the pop-up. Trough there you you can reverse/compare changes up-to certain point. Same way works also NetBeans. For Eclipse, check this. If you used something else you would have to google

@griswolf good suggestions, but did you meat any teacher that has showed students how to use any version control?

...

@griswolf good suggestions, but did you meat any teacher that has showed students how to use any version control?

Yes in a couple of ways:
My 'Introduction to Unix" course mentioned SCCS (this was in the late 80's) and we were required to understand it well enough to pass a quiz, but not to actually use it
My Masters Project was challenging enough that I once placed myself in OP's position (but in C++). At that point, I most certainly did learn how and did use SCCS (which is very primitive compared to modern systems).
Since then, I've never worked on a project with more than one programmer where we didn't use something; and of course, knowing my own needs, I have something for my personal projects as well (mostly, it is Subversion, for my sins: I'm too lazy to learn yet another one at this time)

Off-topic
@griswolf what can I say, you been lucky to study in the times when schools been competing for advance knowledge and topics they presented. At the moment study in UK is badly lagging behind industry expectations. I finished my masters two years ago, but never used version control through my studies or hardly been told about it more then "industry projects often use version control". It was only shortly before finishing study that I started attending Java meetups in London when I was like "o my god, I need to learn all this?" Hopefully in following years UK university may finally move from their ridiculous stand "we are preparing academics that will innovate and lead development teams" to "we are preparing individuals that has good ground up knowledge and waiting to shine"

Off-topic
@griswolf what can I say, you been lucky to study in the times when schools been competing for advance knowledge and topics they presented. At the moment study in UK is badly lagging behind industry expectations. I finished my masters two years ago, but never used version control through my studies or hardly been told about it more then "industry projects often use version control". It was only shortly before finishing study that I started attending Java meetups in London when I was like "o my god, I need to learn all this?" Hopefully in following years UK university may finally move from their ridiculous stand "we are preparing academics that will innovate and lead development teams" to "we are preparing individuals that has good ground up knowledge and waiting to shine"

Well, that is a whole big debate of its own. In the US, typically, the 'state' universities teach you how to do the work, and the 'universities' teach you the theory. There are good points on both sides. I went to Oregon State University where I learned C, Unix, and how to think about computer languages. Nearby, others went to University of Oregon where they learned Scheme and how to think about the theory of computing. I became an engineer (well, I became a better educated one: I was already an engineer, I just didn't know it yet). The other folks became scientists. Both roles are important and valuable. But I do agree: Version control is much more about engineering than theory.

back on topic: a decompiler may get you your code back, based on the .class file.
for simple programs, the JAD decompiler always worked for me.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.