The epicentre in the Indian Ocean was 24 km miles deep, the US Geological Survey said, after initially estimating it at 10 km underground, and 277 kilometres south of the Javanese coast.
Indonesian seismologists put the magnitude at 7.1 and issued a tsunami warning, saying the tremor had the potential to cause a killer wave and asking recipients of its public alert SMS to warn others of the danger.
The warning was later cancelled.
When the quake struck hundreds of residents in the seaport town of Cilacap fled inland and to higher ground by motorbike, car and on foot, an AFP reporter said.
"They were all panicking and shouting ''quake, quake''," the reporter said.
Suharjono, the technical head of Indonesia''s Meteorology and Geophysics Agency, who like many Indonesians uses only one name, said shaking from the tremor had been felt in Pangandaran and Cilacap districts in Java.
"This quake roused people from their sleep," he said. "We have not received any reports of damage or casualties so far."
The US Pacific Tsunami Warning Centre had said that there was no risk of a widespread destructive wave, but there was a "very small possibility of a local tsunami".
The earthquake epicentre was 241 km from the remote Australian territory of Christmas Island, and seismologists said the tremor was felt there, but no tsunami warning alert was issued for Australia.
"We had reports from there that they felt it," Geoscience Australia seismologist David Jepson told AFP, adding that it was described as a "moderate type quake".
Geoscience Australia put the quake at 6.7 magnitude.