British Transport Police launched an investigation after Tyrone Warren tried to rob the teenager on a train as he travelled to buy drugs.
Warren, of Winchmore Hill, north London, was sentenced to four-and-a-half years in jail by a judge at Reading Crown Court, British Transport Police (BTP) said.
The boy, then aged 13, was approached by Warren on May 24, 2008, as their train approached Wargrave station near Reading, a spokesman for the force said.
Pc Aaron King, who investigated the incident, said: “Warren threatened the boy and tried to rob him while shouting ‘I’ve got Aids, give me your money’.
“He then stabbed the boy with a syringe, which had been used previously to inject drugs, causing a puncture wound to the boy’s upper arm.”
Warren dropped the syringe as he fled empty handed from the train at Wargrave. It was later found by police, who traced Warren after matching his profile with DNA found in the syringe.
Pc King added: “For a young boy of just 13 the fear of being confronted and stabbed with a syringe like this must have been awful.
“Thankfully, the DNA evidence seized was vital in linking Warren to the crime and we welcome the court’s decision to jail him for a truly despicable crime.”
The boy was taken to hospital but did not suffer any long-term damage. The 200 days Warren spent in custody will count towards his sentence.