Aren't they bound by international treaty and armistice after WWII not to? Japan and Germany have been tied down for more than half a century due to their aspirations of world domination. Personally I think they've payed their debts to the world.
Japan is bound by it’s own constitution, Germany has no such constraints. Both are probably bound by international treaty not to build any nukes, but then the nuclear powers are bound not to design and buld a new generation too — this has no effect on their behavior.
Either way though, all the Japanese need to do if they wanted nukes is change the constitution — this isn’t a practical constraint on their ability to build nuclear weaponry. It’s not true, then, that every nation capable of maintaining a nuclear arsenal will do so. There isn’t enough public or political support for the Japanese, or the Germans, or the Australians (and so on) to build nukes, so they don’t.