"We've tried just about everything, even putting rolls of barbed wire on the roof, but nothing seems to work," said Mateta Rizahulhaq, a spokesman for the state-owned railway company PT Kereta Api. "Maybe this will do it."
Trains that crisscross Indonesia on poorly maintained tracks left behind by Dutch colonizers six decades ago usually are packed with passengers, especially during the rush hour.
Hundreds seeking to escape the overcrowded cars clamor to the top. Some ride high to avoid paying for a ticket. Others do so because - despite the dangers, with dozens killed or injured every year - "rail surfing" is fun.
The first dozen or so balls were installed last week 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.
But there was a glitch: The chains were too short, leaving a gap of about 16 inches between the balls and the roofs of the passing train carriages. Rizahulhaq said that adjustments would be made.
If successful, the project will be expanded, with balls also set up near railway crossings.
Asked about worries that the balls could hurt or even kill those who defy the roof-riding ban, he insisted that wasn't 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 hard-core 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."
Many of the roof riders - and regular passengers - say the main problem lies with Indonesia's dilapidated railway system. There are not enough trains to meet demand, they say. And there are constant delays in service.
"People have jobs! They can't be late," said Parto, a trader at the Jakarta stock exchange, who can usually be found sitting inside. "If the train is late, they'll do whatever they have to."
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 travelers. But roof riders destroyed the equipment soon after. The exhortations of clerics didn't work. Neither did the dogs.
At one point, police decided to do the expected: Arrest the culprits. But their officers were pelted with rocks and they gave up.