The golden rule states that you must treat others the way they want to be treated, because you would treat yourself the way you would like to be treated, it does not state to treat them in any specific way that you would like to be treated. Just a tip: when reading the Bible, try to think as general as possible.
If one does not respect the Rule, then the Rule does not apply to them.
The criminal is not subject to the golden rule, because (s)he has violated it and thus become a criminal. So, the judge is doing nothing wrong in sending the criminal to jail.