There was no risk of injuries or damage from the quake, which hit at 9:02 a.m. (0002 GMT), the agency said.
The focus of the tremor was close to the surface of the earth and 140 km (90 miles) off the northwestern coast of Okinawa.
Exxon Mobil Japan group refiner Nansei Sekiyu KK's Nishihara refinery in the area was unaffected by the quake and was operating as usual, an official at the refiner said.
Earthquakes are common in Japan, one of the world's most seismically active areas. The country accounts for about 20 percent of the world's earthquakes of magnitude 6 or greater.