Indonesia has come up with another bizarre plan to stop commuters riding on the roofs of trains - hit them with brooms drenched in putrid gunge.

"For anyone who is still up there, it'll be like a whip," said Ahmad Sujadi, of the state-run railway PT Kereta Api Indonesia. The contraptions will be installed at select crossings.

Indonesia has tried just about everything to prevent passengers from clambering on to the roofs of the trains which criss-cross its main island of Java, including spraying them with paint guns, calling in sniffer dogs and asking for help from Muslim clerics.

However, it was not until last month that one of their tactics actually worked. In a few places along the track, grapefruit-sized concrete balls have been suspended on chains from a frame that resembles a football goal. Realising they could suffer serious injury or even be killed, the 'rail surfers' quickly called it quits.

Buoyed by the success, railway officials decided to try the brooms as well. They will start setting them up along the line linking the capital, Jakarta, and the West Java town of Bogor.

Mr Sujadi said he was unmoved by criticism of all the strange and strict security measures.

"Some people say it's inhumane, but that's fine," he said. "Because letting them ride on the roofs is even more inhumane."

Hundreds of people have climbed on to the roofs of trains in the past because they want to escape overcrowded carriages, cannot afford the price of a ticket, or because they think it is more fun.

However, dozens of people are killed or injured every year after falling off the train or by being electrocuted by power lines.