Keep in mind that this will not be a peer-to-peer kind of relationship; however, that does not mean it cannot be genuine.
You might make that the king or whoever is in charge has entrusted the safety (and perhaps the instruction) of the boy to this war commander. Another way to go about this would be to have the boy badly want to learn whatever skill it is he admires in the commander (horse riding, swordplay, etc, depending on the time period you are writing about). Perhaps the commander is reluctant at first, but gradually he begins to notice the skill and maturity of the boy--add in the bit about the younger brother, who he is reminded of, and you have a relationship that grows stronger with time.
A tip: Something in each of your characters must be attracted to something else in the other character to make the relationship work. Consider having the commander remember his own boyhood when he was eager to learn, or something about his boyhood that reminds him of the prince--perhaps deep inside he is still a boy at heart, though a mature one, and thus can relate to this younger person. And/or have the prince demonstrate maturity for his age that the commander secretly (or not so secretly) admires. He sees the potential in the boy to become a great warrior.
The king (the prince's father) could be a strict, overbearing man, or he could be a good father--it doesn't really matter. The friendship in question might differ in nature depending on this, however. Another thing you could do is liken the relationship to a father-son relationship. Perhaps both characters have gaps in these areas that need to be filled or supplemented with this relationship. If this is not the case, the teacher/mentor/guardian scenario works well--and as I mentioned in my above comment, you could even have this commander be like a second father to the prince. Or perhaps he gets to be that way over time. Maybe the king dies and the prince turns to the commander for guidance. The possibilities seem endless...
Any way you slice it, it can certainly be a genuine friendship, even if it is not a peer-to-peer relationship.