In 1975, biological warfare between China and Russia kills most of the world's population. U.S. Army Col. Robert Neville, M.D. is a scientist based in Los Angeles. As he begins to succumb to the plague himself, he injects himself with an experimental vaccine, rendering himself immune.
By 1977, Neville believes he is the plague's only immune survivor. Struggling to maintain his sanity, he spends his days patrolling the deserted city of Los Angeles, hunting and killing members of "The Family", a cult of plague victims who were turned into nocturnal albino mutants. The Family seeks to destroy all technology and kill Neville, who has become a symbol of the science they blame for humanity's downfall. At night, living atop a fortified apartment building equipped with an arsenal of weaponry, Neville is a prisoner in his own home.
One day, as Neville is in a department store helping himself to new clothing, he spots a woman who quickly runs away. He pursues her outside but later decides he is hallucinating and dismisses the sighting.
On another day, the Family finally captures Neville. After a summary trial he is found guilty of heresy by the family's leader, Jonathan Matthias, a former news anchorman. Neville is sentenced to death and nearly burned at the stake in Dodger Stadium. He is rescued by Lisa, the woman he had earlier dismissed as a hallucination, and Dutch, a former medical student. Lisa and Dutch are part of a group of survivors, some of whom are children. Although their youth has given them some resistance to the disease, they are still vulnerable to it and will eventually succumb to mutation. Neville realizes that even if it is possible to duplicate the original vaccine, it would take years to salvage humanity. However, he believes it may be possible to extend his immunity to others by creating a serum from his own body.
Neville and Lisa return to Neville's apartment where they begin treating Lisa's brother Richie, who is succumbing to the disease. Neville and Lisa are about to have a romantic evening together just as the generator runs out of fuel and the lights go off. The Family then attacks, sending Matthias' second-in-command Brother Zachary to climb up the outside of Neville's building to the open balcony of his apartment. Neville leaves Lisa upstairs as he goes to the basement garage to restart the generator. Neville returns to the apartment to find Zachary right behind an unsuspecting Lisa. Neville shoots him and he falls off the balcony to his death, dropping his spear on the balcony as he goes.
If the serum works, Neville and Lisa plan to leave the ravaged city with the rest of the survivors and start a new life in the wilderness, leaving the Family behind to die. Neville is successful in creating the serum and administers it to Richie. Once cured, Richie reveals the location of The Family's headquarters to Neville, but insists that the Family are also human and that Neville's cure should be administered to them as well. Neville disagrees with him, so Richie goes to the Family by himself to try to convince them to take the serum. Matthias refuses to believe that Neville would try to help them, accuses Richie of being sent to spy on them and has him executed. Neville discovers Richieâs body and, enraged, goes on a rampage against the Family.
Meanwhile, Lisa quickly and unexpectedly succumbs to the disease and becomes one of the Family. Returning home, Neville tells Lisa about Richie's death, but she already knows and has betrayed Neville by giving Matthias and his followers access to Neville's home. Matthias, who finally has the upper hand, forces Neville to watch as the Family sets his home and equipment on fire. Neville breaks free and, once outside with Lisa, he turns and raises his gun to shoot Matthias, who is looking down from the balcony. The gun jams, giving Matthias enough time to hurl Zachary's spear at Neville, mortally wounding him. The next morning, Dutch and the survivors discover Neville dying in a fountain. He hands Dutch a flask of the blood serum, and then dies. Dutch takes away Lisa (weakened and compliant because of the sun) and the survivors as they leave the city forever.

Question: How does Robert Neville become immune to the virus?
Answer: He injects himself with a experimental vaccine
Alternative answer: By injecting himself with vaccine.