What is meant by the great men that are in the Earth 2samuel 7v9?

The great men that are in the earth are " The two Children of Israels, and they are a good spirit and an evil one.The Good is like for example, David, Abraham in the Old Testament and in the New, that would be "Christ". While the "Evil" are known by different names but are generally consistent with the likes of Satan.

It must be noted that God is of the living and not of the dead.

Jewish answer:

Let's take a look at the verse in context, without allegory or metaphor. After King David expresses readiness to build the First Temple, here is part of God's answer to David, spoken through the Prophet Nathan:

"Thus says the Lord of hosts: I took you (David) from the sheepcote, from following the sheep, that you should be prince over My people, over Israel. And I have been with you wherever you did go (in all your endeavors), and have cut off all your enemies from your presence; and I will make you a great name, like the name of the great ones that are in the earth."

So the phrase simply means: the righteous people who have already died.