Javert is a difficult character. People want to believe he's the bad guy but he's not. He believes he's doing right, he's doing his job. He was unappreciated as a child so as an adult he strives to excel and even obsesses over it. He killed himself because he felt he failed. He's not a bad guy, he's just human.