A Latin expression often translated virtue out of necessity.
This is sometimes interpreted as a piece of advice, similar to the English saying if life serves you lemons, make lemonade.
While that is certainly a very good piece of advice, it is really not what ex necessitate virtus means. The order of the words is important here, even if it is in Latin.
The ex necessitate (out of necessity) part is actually meant as a modifier of the virtus (virtue). Hence, a better translation is (the) out-of-necessity virtue.
The underlying idea behind the expression is sarcasm or disgust. It is often used as a commentary or criticism.
Typical usage is as a reaction to someone blabbering about his accomplishments, taking credit for things he has done only because he was forced to do them by circumstances, though would have never done them out of the goodness of his heart.
That kind of blabber is common among, but not limited to, politicians.
Saying ex necessitate virtus as a reaction to that blabber is akin to saying oh, give me a break, or oh, please, or even shut up already, but is more specific because it clearly states why you would want someone to shut up already.