It's funny, the whole java applet thing was actually a better solution than JS in a lot of ways (shipping compiled/compressed bytecode with a security manager), just way, way ahead of it's time, and with a terrible windowing/drawing toolkit that meant it would never be adopted.
I think that in the mobile side it actually went the way you describe.
In japan docomo offered an open java platform (free to use, free to install, no gatekeeper for standard apps). Mobile html was only useable for dead simple things, there was no js of course, and any service with mildly complex things to do or show would be better to implement in it's own app. It sounds terrible, but the user experience wasn't that bad.
The terrible toolkit part was solved by Docomo shipping it's own UI toolkit (no J2ME compatibility, but it was so much more useable), and I think at some point there was a way to launch an app from the browser without installing it but I'm not sure my memory serves me well.
The choice of java was made for security of course, and I never heard of any serious breach in 10 years following the mobile tech news.
We get the same phenomenon I guess with the "go the mobile app" redirects on websites that don't want to have x optimized versions of the same service.