All countries in a theatre of war naturally had to protect their shorelines.
Until the First World War, this protection was aimed exclusively at defending against naval attacks. Once aircraft began to be used in warfare, coastal protection rapidly shifted to include anti-aircraft protection. Large bore, long range anti-ship batteries were supplemented or replaced by anti-aircraft or "ack ack" batteries. These weapons had to adjust their aim very quickly and fire rapidly. They fired mainly small, high explosive shells.
Although far from Japan and Germany, Canada and the USA were very concerned about coastal attacks throughout WWII. Canada had ack ack batteries along both coasts. Key inland industrial production sites were also protected with ack ack batteries and many towns had regular blackout drills.