I tried to look for prior threads on this - my second time actually - and I am surprised no one has asked this, at least not that I can find.
So why don’t we have a problem swearing on the bible in front of a judge, when the bible says don’t swear on anything?
This topic seems to be addressed in the
2142-2155*Catechism of the Catholic Church, *, in its discussion of the Second Commandment, especially in 2153-2154:
2153 In the Sermon on the Mount, Jesus explained the second commandment: “You have heard that it was said to the men of old, ‘You shall not swear falsely, but shall perform to the Lord what you have sworn.’ But I say to you, Do not swear at all. . . . Let what you say be simply ‘Yes’ or ‘No’; anything more than this comes from the evil one.”(82) Jesus teaches that every oath involves a reference to God and that God’s presence and his truth must be honored in all speech. Discretion in calling upon God is allied with a respectful awareness of his presence, which all our assertions either witness to or mock.
2154 Following St. Paul,(83) the tradition of the Church has understood Jesus’ words as not excluding oaths made for grave and right reasons (for example, in court). “An oath, that is the invocation of the divine name as a witness to truth, cannot be taken unless in truth, in judgment, and in justice.”(84)
(82) Matthew 5:33-34, 37; cf. James 5:12.
(83) Cf. 2 Corinthians 1:23; Galatians 1:20.
(84) Code of Canon Law, canon 1199 § 1.