Why are all the Japanese buildings blue and the Chinese buildings orange/yellow?

In East Asian culture, blue represents heaven while orange/yellow represents earth. Orange/yellow is a color reserved for royalty/imperial family only, so I don't see why all the Chinese buildings have this color...