The quake occurred at 1:34 p.m. and lasted less than a minute, but it prompted thousands of people in Jakarta to flee buildings, including lawmakers at the House of Representatives in Central Jakarta.
According to the US Geological Survey, the magnitude 6.0 quake was centered off western Java at a depth of about 43 kilometers.
There were no reports of fatalities, but the government said six students were seriously hurt after the roof collapsed at their high school at Cianjur on Java island near the epicentre of the quake. Two other students suffered minor injuries.
Bureau office on the 16th floor, the tremors could also be felt and all the staff were ordered to gather outside the building before being allowed to re-enter it at 2.15 pm.
Huge 8.1 magnitude quake strikes near USA coast with tsunami warning issued
If a tsunami has been generated in this location it is not likely to arrive in New Zealand for at least 12 hours. People reported on social media that the quake was felt hundreds of miles away, in Anchorage.
"I was just sitting down, then I felt the building swaying", said Rudy Togatorop, 35, who works at the Chilean embassy. There was no Tsunami warning issued. It shook some buildings in the capital Jakarta, about 100 kilometres from the location of the quake. Metro TV showed patients being evacuated from a hospital, Reuters reported.
"I'm calling on people to be prepared, especially if you are in buildings with a weak structure", he added. Indonesia sits on the Pacific "Ring of Fire" where tectonic plates collide, causing frequent seismic and volcanic activity.
Meanwhile, homes and buildings have collapsed and dozens of people have been injured after a magnitude-6.1 natural disaster in Indonesia.
In 2004, a powerful quake in the northern part of Sumatra Island triggered a tsunami in the Indian Ocean that killed around 230,000 people in a dozen countries, mostly in Indonesia.