I needed to obfuscate some code for a project I'm working on. A quick search came up with yGUARD which is surprisingly well-suited for my purposes.
For one thing you can specify the granularity of obfuscation, right down to the method and field level. So for example you can tell it to obfuscate a single field in a single class (and all references to it, obviously), up to every field and method in every class in a jarfile, or anything in between.
Another nice feature is that it operates seamlessly with ant, and therefore, with NetBeans. Add a new target to build.xml, then invoke it with with the
-post-jar target provided by NetBeans, and the generated jar is now obfuscated automatically at every build. Very slick.
yGuard's method of obfuscation is to rename methods and variables with obscure, sometimes unprintable, names. It also has a code shrinking option which according to their specs removes code entities that can not be reached from a set of given code entry points.
Two thumbs up.