Like Oliver, I used to have some clunky ant scripts that called JDepend and tried to determine whether JDepend had detected any package cycles. It works, but as you can see from Oliver's blog it's harder than it really should be.

With classycle it's incredibly simple.

Here's a (trimmed down) classycle rules file:

        show allPaths onlyFailures  
        {root} = com.example.system  
        [all] = ${root}.*  
        check absenceOfPackageCycles > 1 in [all]

It checks all the classes in the com.example.system.* packages. The only rule that I've specified here is to check for package cycles, but classycle is much more powerful than that, and we use it to check layering, and to check that our package dependencies conform to certain rules (e.g. com.example.system.ui and com.example.system.persist must be independent of one another)

Here's the ant snippet to drive it:

        <classycleDependencyCheck 
         definitionFile="classycle.ddf"
         failOnUnwantedDependencies="true"> 
                <fileset refid="fileset.classes" /> 
        </classycleDependencyCheck>

(You'll need to add the appropriate taskdef for classycle)

Like Oliver I'm a big believer in setting up automated tools to prevent spaghetti code - I just think classycle is a simpler tool than JDepend.