The magnitude 7.5 quake hit at 0005 on Thursday (1705 GMT Wednesday) at a depth of 289km (180 miles).
No immediate casualties or damage were reported. Because of the depth, there was little risk of a tsunami, the Pacific Tsunami Warning Center said.
A massive undersea earthquake sparked a tsunami that killed more than 130,000 people in Indonesia in December 2004.
Thursday's quake hit 100km (60 miles) east of Jakarta.
Residents panic
Residents of the capital said buildings shook violently during the quake and its aftershocks.
This [quake] was felt by people on the ground and it shook buildings, but it was too deep to cause the ocean bottom to move
John Bellini
USGS geophysicist
Hundreds of people gathered in the courtyards of Jakarta's vast apartment blocks, too scared to go back inside, said the BBC's Lucy Williamson in Jakarta.
One resident described being woken up on the 26th floor of her apartment by the swaying of her building.
The tremor was felt as far away as Malaysia, according to the US Geological Survey (USGS).
"The earthquake centre in 2004 was close enough that it actually ruptured the surface of the sea floor, which caused a tsunami," USGS geophysicist John Bellini told the Associated Press news agency.
"This one was felt by people on the ground and it shook buildings, but it was too deep to cause the ocean bottom to move."
Earthquakes and tsunamis are frequent in Indonesia, part of the seismically active Pacific "Ring of Fire".
Location of earthquake shown by blue star.
According to the United States Geological Survey (USGS) a powerful magnitude 7.5 earthquake struck Indonesia's main island, Java, at 5:05 p.m. UTC, which is just after midnight locally.

The epicenter was located 100 kilometers (65 miles) east of Jakarta and was at a depth of 289.2 km (179.7 miles). The Pacific Tsunami Warning Center said that no tsunami is expected as the depth of the quake exceeded 280 km.

There are no reports of damage, injuries or deaths.

"No reports of damage or casualties have been received at this time. Because this earthquake is located about 290 km below the surface of the earth, it will have been felt strongly over a wide area, but is not likely to cause severe damage. We have received reports that the earthquake was felt in much of Java and in parts of Malaysia", said a statement posted on the USGS website.