“and walk in the ways of your heart and in the sight of your eyes.” This seems to be surprising advice since Moses seems to have said the opposite: “remember all the commandments of Yahweh and do them, so that you do not follow after your own heart and your own eyes” (although the verbs in Numbers differ from the verbs in Ecclesiastes). It is very possible that this is the Sage’s advice to the young man who is just learning about life, and telling the young man to follow his heart and eyes, and thus learn about life, but in the learning keep in mind that there is a judgment coming. The exhortation throughout Ecclesiastes is that we are to enjoy life, but that enjoyment has boundaries that must be learned, often by experience. The Sage is not being sarcastic or tongue-in-cheek here and saying to the young man, “You can follow your heart but you will suffer for it.” He is encouraging the young man to discover the proper boundaries of life. Enjoy life, but keep in mind the Judgment Day that is to come, and set your boundaries accordingly.
“for all these things God will bring you into judgment.” That God will judge people for how they have lived and what they have done is stated several times in Ecclesiastes (cp. Eccles. 3:17; 11:9; 12:14).