Did the Buddha himself say anything about 'greater good'? The phrase comes up -- especially when discussing 'militarism' -- in the secondary literature; e.g.


  that “one must sacrifice the lesser good for the greater good”; so too
  must “our heroes sacrifice their lives in order to preserve the naition...


Buddhism and Politics in Thailand, p154

Did the Buhddha say anything like this? The closest I know of is "be a lamp unto yourself", but in effect that could legitimize all sorts of errors.

Specifically I mean examples analogous to serving in the military: when some wrong doing is permitted due to "the greater good".
If this is the lesser good:


  AN4.95:2.2: The person who practices to benefit neither themselves nor others is like this, I say.


Then this is the greater good:


  AN4.95:3.1: The person who practices to benefit others, but not themselves, is better than that.


If this is the lesser good:


  AN4.95:3.2: The person who practices to benefit themselves, but not others, is better than both of those.


Then this is the greater good:


  AN4.95:3.3: But the person who practices to benefit both themselves and others is the foremost, best, chief, highest, and finest of the four.


Notice in particular that "heroes sacrificing themselves for the nation" is only third best. There are two practices better than that. Indeed, one reads that practicing to benefit oneself is better than being a hero. But to understand this fully, one must also know that practicing to benefit oneself requires one to make progress on the Noble Eightfold Path. The first step of the Noble Eightfold Path is Right View. And that Right View includes the direction to perform good deeds.


  MN117:6.1: And what is right view?  Right view is twofold, I say. There is right view that is accompanied by defilements, has the attributes of good deeds, and ripens in attachment.  And there is right view that is noble, undefiled, transcendent, a factor of the path.


The greatest good, however, is to practice to benefit both ourselves and others. And how do we practice to benefit others? We teach them Right View.


  AN2.126:1.1: “There are two conditions for the arising of right view.  What two?  The words of another and proper attention.  These are the two conditions for the arising of right view.”