Rail bosses in Indonesia have come up with a painful method of deterring passengers taking a free ride on carriage roofs.

Rows of grapefruit-sized concrete balls have been put up to rake over the top of trains as they pull out of stations, or when they go through rail crossings.

"We've tried just about everything, even putting rolls of barbed wire on the roof, but nothing seems to work," said a spokesman for the state-owned railway company PT Kereta Api. "Maybe this will do it."

Trains that criss-cross Indonesia on poorly maintained tracks left behind by Dutch colonisers sixty years ago usually are packed with passengers, especially during the rush hour. Hundreds seeking to escape the overcrowded carriages climb on the top. Some to avoid paying for a ticket, others because - despite the dangers, with dozens killed or injured every year - "rail surfing" is fun.

The first dozen or so balls were installed hundreds of yards from the entrance of a train station just outside the capital, Jakarta. Painted silver, the balls hung by chains from what looked like the frame of a giant soccer goal.

Asked about worries that the balls could hurt or even kill those who defy the roof-riding ban, the spokesman insisted that was not really his problem. "They don't have to sit on top," he said. "And we've already told them, if the train is full, go to the office. We will be happy to reimburse their tickets."

The commuters, known as "Atappers" or "Roofers," meanwhile are hardcore in their determination to stay on top.

"I was really scared when I first heard about these balls," said Mulyanto, a 27-year-old shopkeeper, who rides between his hometown of Bogor and Jakarta almost every day for work. "It sounds like it could be really dangerous."

"But I don't think it'll last long," he said. "They've tried everything to keep us from riding ... in the end we always win." "We like it up there, it's windy, really nice."

Several years ago, paint guns were set up to spray those riding on the top of carriages so authorities could identify and round up the guilty travellers. But roof riders destroyed the equipment soon after. The exhortations of clerics did not work. Neither did using guard dogs.