Presents your JAVA E-NEWSLETTER for March 20, 2003 <-------------------------------------------> RETRIEVE LOST SOURCE CODE The reasons for losing source code are numerous: failed backups, failure to backup, lost laptops, crashed hard drives, etc. Though most programmers will experience this problem at some point in their careers, the good news is regenerating the source code for a regular Java class file is not difficult. The process of generating source code from class files is called decompiling. There are many programs out there that will decompile Java class files, but a popular one is the Java Decompiler (JAD). JAD is a command-line tool that you run against a class file or a set of class files, and it's available for most popular operating systems. http://kpdus.tripod.com/jad.html When you run JAD against your classes, you'll get a source file for each class that was decompiled. Once you have the source code, you can make changes, recompile, and back up your source code so you won't have to use a decompiler in the future. Here is an example of a JAD command line: jad Employee.class Parsing Employee.class... Generating Employee.jad DISCLAIMERS ABOUT JAD Java class files are relatively easy to decompile; therefore, there's now a market for tools that protect class files from being decompiled. The tools that provide this protection are called obfuscators. If the class files you're trying to decompile have been obfuscated, then JAD or other programs like it may not successfully generate source code for these classes. Decompilers don't recreate original source code; they merely generate equivalent source code. Source code comments never make it to the decompiled class file, so if you lose your source code, you also lose all your comments. With proper backup procedures, you may never need to retrieve lost source code; but if you do, you may find JAD useful. ----------------------------------------