People in the town of Adipala near the epicentre said they felt the ground shaking hard for up to 20 seconds, as the quake struck in the sea off the coast of southern Java.
"We all just ran onto the street, there were so many people," Astri, a florist who goes by one name, told AFP by phone from her flower shop.
"But it doesn't seem to have damaged anything around here, and we're getting back to work," she said.
The quake struck at 12:14pm (0514 GMT) 39 kilometres (24 miles) south-southeast of Adipala at a depth of 83 kilometres, the USGS said.
Indonesian officials said there was no risk of a tsunami and no immediate reports of damage or casualties.
"We don't expect a lot of damage because the quake was deep, but we will monitor as it was felt quite strongly on the coast near the epicentre," meteorology, climatology and geophysics agency technical chief Suharjono told AFP.
Indonesia sits on the Pacific "Ring of Fire", where tectonic plates collide, causing frequent seismic and volcanic activity.
A 6.1-magnitude quake that struck Aceh province on Sumatra island in July 2013 killed at least 35 people and left thousands homeless.