A judicial foreclosure is a little different from a non-judicial foreclosure and its one you're less likely to run across. A judicial foreclosure is not used very frequently but there are situations where a court has to step in and the foreclosure has to be processed under their guidance. A non- judicial foreclosure is done without a state court's intervention.
One time when judicial foreclosures occur is when the homeowner owes the government taxes on the property. In these situations the government can file a lawsuit that requests that the property be sold and the proceeds will go toward those past due taxes While this does require the intervention of a court it doesn't really have the air of a trial, the government simply has to prove the taxes are owed and the home will go into foreclosure.
Your mortgage servicer can also request a judicial foreclosure but they can proceed along the traditional route of a non-judicial foreclosure just as easily. Most mortgage lenders will decide to forego the judicial foreclosure because it simply takes too long and the extra burden of having a judge involved is an unnecessary added step.
If you do find yourself tied up in a judicial foreclosure it's often a good idea to have an attorney at your side to represent you in court. While you may not have much of a defense or argument against the foreclosure it's still a good idea to have your own legal representation.