One who begins the development of unselfish joy should not start with dearly beloved person, a neutral person or hostile person. For it is not the mere fact that a person is dearly beloved, which makes him an immediate cause of developing unselfish joy, and still less so neutral or hostile person. Persons of the opposite sex and those who are dead are not suitable subjects for this meditation.
A very close friend, however, can be a suitable subject. One who is called in the commentaries an affectionate companion; for he is always in a joyous mood: he laughs first and speaks afterwards. He should be the first to be pervaded with unselfish joy. Or on seeing or hearing about a dear person being happy, cheerful, and joyous, unselfish joy can be aroused thus: "This being, verily, is happy! How good, how excellent!" For this is what is referred to in the Vibhanga: "And how does a bhikkhu dwell pervading one direction with his heart imbued with unselfish joy? Just as he would be joyful on seeing a dear and beloved person, so he pervades all being with unselfish joy" (Vibhanga 274).
But if his affectionate friend or the dear person was happy in the past but is now unlucky and unfortunate, then unselfish joy can still be aroused by remembering his past happiness; or by anticipating that he will be happy and successful again in the future.
Having thus aroused unselfish joy with respect to a dear person, the meditator can then direct it towards a neutral one, and after that towards a hostile one.
But if resentment towards the hostile one arises in him, he should make it subside in the same way as described under the exposition of loving-kindness.
He should then break down the barriers by means of impartiality towards the four, that is, towards these three and himself. And by cultivating the sign (or after-image, obtained in concentration), developing and repeatedly practicing it, he should increase the absorption to triple or (according to the Abhidhamma division) quadruple jhana.
Next, the versatility (in this meditation) should be understood in the same way as stated under loving-kindness. It consists in:
(a) Unspecified pervasion in these five ways:"May all beings... all breathing things... all creatures... all persons... all those who have a personality be free from enmity, affliction, and anxiety, and live happily!"
(b) Specified pervasion in these seven ways: "May all women... all men... all Noble Ones... all not Noble Ones... all deities... all human beings... all in states of misery (in lower worlds) be free from enmity, etc."
(c) Directional pervasion in these ten ways: "May all beings (all breathing things, etc.; all women, etc.) in the eastern direction... in the western direction... northern... southern direction... in the intermediate eastern, western, northern, and southern direction... in the downward direction... in the upward direction be free from enmity, etc."
This versatility is successful only in one whose mind has reached absorption (jhana).
When this meditator develops the mind-deliverance of unselfish joy through any of these kinds of absorption he obtains these eleven advantages: he sleeps in comfort, wakes in comfort, and dreams no evil dreams, he is dear to human beings, dear to non-human beings, deities guard him, fire and poison and weapons do not affect him, his mind is easily concentrated, the expression of his face is serene, he dies unconfused, if he penetrates no higher he will be reborn in the Brahma World (A v 342).
by Ven. Buddhaghosa (fifth-century) Excerpted from The Path of Purification (Visuddhimagga).