An earthquake with a preliminary magnitude of 4.8 hit eastern Japan on Friday, shaking buildings in the capital Tokyo.