https://www.joelonsoftware.com/2002/06/12/strategy-letter-v/
If you sell hardware the last thing you want to do is commoditize hardware, which is what a portable software strategy does. What you want is hardware lockin. Java was the opposite of that. Sun eventually had to be sold, but Microsoft didn't.
Sun bought into Netscape's vision of the web as the delivery platform for software. Java could run on the server side and then as applets in the browser on the client. The expansion of Java would then expand its use in places Sun wanted to charge for licenses.
Java wouldn't create a moat around their hardware. It was intended to eliminate Microsoft's moat around the Windows platform. If ISVs could write software in Java that could be delivered by a browser on any OS, the actual OS stopped being important. As long as there was a browser and JVM available on a platform it could run that software.