Jacobe - Java Pretty-Printer

One of the common pitfalls of Java programming (and indeed, of programming in most languages other than Python) is getting the indentation wrong, i.e. inconsistent with your language statements. When this happens, the Java compiler will not interpret your program in the same way as a typical human reader. Needless to say, this can cause no end of grief when you are debugging.

A simple way to correct this problem is with an automatic code formatter, sometimes called a pretty-printer. Such a formatter reads your source code in the same way that the Java compiler will, and then it fixes up the formatting so that all the indentation will be correct.

This page tells you how to download and install the free formatter called Jacobe. This is certainly not the only one available, and it may not be the best one in all situations, but it works well from the command line and is simple to install. You are not required to use it, but I encourage you to try it out.

Now to format a file like Foo.java, just type
jacobe Foo.java
at the command line prompt. The original file will be cleaned up, and there will be a new file called Foo.java.jacobe which contains the contents of the original file, to serve as a backup in the unlikely event that something goes wrong during formatting.

The config file I supply you with matches the coding style that I use in class, but Jacobe is configurable to match many different styles. If you want to change the configuration (e.g. to match a different professor's style or a coding standard at a particular company), you will need to download the Jacobe User Manual, from a link lower on the Jacobe home page listed above.