One way is through a plea bargain. This is an agreement on the punishment that will be issued if the defendant pleads guilty or no contest. In exchange for being able to resolve the issue, the defendant may receive a reduced penalty.
The case may go to trial and this can be before either the judge or a jury. The defendant has the absolute right to a trial by jury, but the accused may waive the right to a jury trial and let the judge of the court decide the case. Usually a trial, whether in front of the judge or a jury, is to determine whether or not the accused is guilty, and if so, what the punishment should be.
A third possibility is through an open plea, also referred to as a non-negotiated guilty plea. Through this, the defendant may plead no contest or guilty without having any type of agreement with the prosecution in regards to the penalties that they will face. When this happens, there is a contested trial before the judge or a jury to assess the case and determine what punishment the defendant will receive.
Finally, the case may be dismissed by the court after a recommendation to dismiss the case is made by the prosecutor. This is the least common way that cases are resolved. Dismissal of a case is fact-specific, and dismissals are always on a case by case basis. If the prosecutor believes he may get a conviction, the case will usually not be dismissed.