North Korea has fired a submarine-launched missile towards Japan, showing the isolated country has improved its technological capability.