Determinism doesn't necessarily mean that organisms always act in the same way. They act in the same way given the exact configuration of them and the world.
Obviously, justice changes the configuration of an organism (fines, prison, ...). To me it boils down to the question whether justice decreases the likelihood to commit crimes again. Given that our systems of justice have evolved over a long time, I'd give them the benefit of the doubt.