Regardless of the number of classes in a source file, Java compilers that follow Sun's Java scheme will compile one class per file. This program reads the compiled class and dumps it in a readable form, akin to Java source.
java javad.main classfile-list
For example: java javad.main one.class two.class three.class
I wanted to understand the Java class file format. This was critical for my work on my Java compiler, since a Java compiler must be able to read class symbol information from the .class file. The "javad" program was written in Java because I wanted to write a semi-sizable application in Java to get a feel for Java class structure versus C++.
A number of Java class file disassemblers have been written. One of these is shipped in binary form with the Sun Java release (javap). There are several class file disassemblers available in source form. These include:
Djava
Djava is a Java class file disassembler written in C. This program is available from a number of sites, including http://www.sco.com/skunkware/98/java/. The program was written by Shawn Silverman. Apparently a Java version of Djava also exists.
Jasper
Jasper is a Java class file disassembler written in Java. I did not find this published on a web page. It was published in a discussion group on object oriented programming. The author is Chris Rathman. I have no idea if this URL will hold up over time, but I found here.
As any Java programmer knows, Java does not use header files to define external classes (e.g., a class that is not in the current file). Information about the structure of a class can be obtained from a .class file. As the javad and the other class file disassemblers show, the much of the original source for the class definition can be recovered from the class file.
Compared to machine code (e.g., x86, powerPC, SPARC), Java byte codes are very high level. A clever piece of software can recover something close to the original source code for the methods. These programs are referred to as decompilers. For those who want to keep their source code secret there are Java code obfuscators.
A list of Java disassemblers and decompilers is published on Marc Meurrens home page.
This page mentions that Hanpeter van Vliet wrote a Java decompiler, named Mocha. Apparently the program does a good job of decompiling Java class files. When it appeared the first response, presumably of some United States citizens, was to threaten to sue. Sanity seems to have asserted itself and no one sued. But it spurred the development of "obfuscators", including van Vliet's own "Crema". A copy of van Vliet's "manifesto" can be found here.
According to this web page, van Vliet died of cancer on December 31, 1996 at age 34, not long after finishing Mocha. The current Mocha release can also be found on Eric Smith's web page
It is interesting to note that at one point Borland/Imprise sent e-mail to Eric Smith claiming ownership of Mocha. The despicable way that some companies treat free software is the motivation for the Bear Products International source license agreement used for Javad.
The European KOPI project has created a Java source to byte code compiler. KOPI also includes byte code assemblers and a class file disassembler. The KOPI project can be found here
Marco Schmidt has published a list of Java compilers and Java VMs. This list can be found here
For copyright and usage permissions for the javad program, see the copyright @author Ian Kaplan