There were some potential solutions (like billing SPARC servers and workstations as "Java development/deployment platforms") that Sun started to brush against, but they ran out of time / money / distance from Oracle's sidaM Touch, etc.
Java actually did/does make them money, most obviously through the Ask Toolbar bundling deal (which is why they still desperately cling to it even though it trashes their reputation and people hate it).
They also get commercial support contracts from it.
And they got money from licensing various trademarks, test suites, J2ME and so on.
But yeah - ultimately Sun weren't able to build a killer business out of Java. They had a variety of small revenue streams but nothing that could compete with Windows.
That was Sun's strategy for Java; it didn't work out well for them. Java became huge, but Sun never did figure out how to make a dollar from it.