Officials said the earthquake, estimated by US monitors at magnitude 6.9, risked generating a tsunami 3 metre (10ft) high. The quake reportedly struck at a depth of 52.8 km at 7.03 p.m.
According to the United States Geological Survey (USGS), the epicentre was in the Sunda Strait, about 104 km from the city of Tugu Hilir in Banten province, on the island of Java.
Tremors were felt in many cities, including Indonesia's capital Jakarta, prompting people to run out of their homes. The earthquake lasted around 40 seconds.
There were no immediate reports of damage or casualties.
The Indonesia's Meteorology, Climatology and Geophysical Agency issued a tsunami warning for four areas. The agency said there was no change in the sea water level in the 40 minutes following the earthquake.
The quake also caused some blackouts, plunging some of the affected areas into darkness.
The Indonesian National Board for Disaster said it was working with local authorities to evacuate people living on the coastline. The board told people in the affected areas to evacuate to higher places.
There was no tsunami threat to other countries along the Indian Ocean, according to USGS data and the Indonesia Tsunami Early Warning System.
Indonesia has a history of devastating earthquakes and tsunamis with more than 2,000 killed last September on the island of Sulawesi.
( With inputs from IANS )