Japan has been hit by a 6.2-magnitude earthquake on its western coast near Hakui.