Those are two words often used to translate the same Gk. word.
A "just" man is "righteous," righteous in someone's eyes, by some standard. A "just" man is not in trouble with the law, but in conformity with it, as judge (or Judge) determines, or has no need to determine. A person not subject to trial is presumed "just" or "innocent." A "justified" man has been cleared by the judge.
I would say that it is often the case, in Scripture and in life, that a "righteous" or just man is simply this: a forgiven man. Certainly, this is true with David, the later David especially, after his sin with Bathsheba. That was an horrific event, but it also shows how that David was already (in one sense) atoned for. See 2Sam.12:13, where in response to David's confession Nathan tells him that God has already put away his sin: "You shall not die." Ps.51 is throughout an acknowledgement of personal unrighteousness, and a vindication of God's righteousness, but at the end speaks of the sacrifice of righteousness. And Ps.32:11 has David calling to his fellow "righteous" to rejoice with him; and vv1-2 are a statement of the forgiveness from God, and the non-imputation of sin/guilt (which is deserved). See also Ps.130:3-4.
There is an external righteousness that is of only limited worth. Only a spiritual judgment is of eternal value. David's external righteousness was completely overthrown by his depraved act. If he were not a child of God by grace and election (in other words, a man like Saul) his repentance would likewise have been limited to externals. That he could repent from the heart showed the work of grace in him, and he was forgiven. God treated David as if he were righteous, imputed his sin to Christ, and Christ's righteousness to him.
As for the translation of "righteousness" as "justice," there could be times when such a rendering is fit. The "righteousness" of God could, if it refers to a display or exercise of divine attribute, be properly translated as the "justice" of God, a reflection on the divine nature itself. But there would also be times when it would better convey the nuance of the original with a word such as "justification" or "justified;" that is, a righteousness from God, or a verdict by God.
Divine righteousness is a "big" term, that has many applications: subjective, objective, active, passive, etc. Doing theology is the art of harmonious integration of original inspired expression in an analytic enterprise, so that we may understand the parts and the whole of God's revelation. We believe Paul isn't self-contradictory, nor is he contradictory with other biblical authors; there is one Mind behind all that inspiration. Translation, therefore, is a big job, and a big deal. It must be done with care, and respect for the human author, that the present reader may be effectively taught by the apostle or prophet himself, ultimately by Holy Spirit himself.