For out of prison he came out to be king; yes, even in his kingdom he was born poor.
out of prison--Solomon uses this phrase of a supposed case; for example, Joseph raised from a dungeon to be lord of Egypt. His words are at the same time so framed by the Holy Ghost that they answer virtually to Jeroboam, who fled to escape a "prison" and death from Solomon, to Shishak of Egypt (Kg1 11:40).
For out of prison he cometh to reign; though also [he that is] born in his kingdom becometh poor. (h) That is, from a poor and base estate or out of trouble and prison as Joseph did, . (i) Meaning, that is born a king.
Ecc 4:14 “For out of the prison-house he goeth forth to reign as king, although he was born as a poor man in his kingdom.” With כּי the properties of poverty and wisdom attributed to the young man are verified, - wisdom in this, that he knew how to find the way from a prison to a throne.