Sometimes I think that, if Java ditched the idea of JVM and followed what modern languages did today (write once, compile on every major platform), things would be different.

I don't think so. Oracle isn’t a consumer-facing company and doesn't really care about that sector. SWT and Swing will likely remain as ugly as they are for the next century, regardless of their popularity.

Microsoft, Google, and Apple have invested millions to polish their GUI solutions because that’s where their revenue comes from.

JavaFX is surprisingly decent. Nobody cares bc the web ate everything.

What's even sadder is that was built and Sun fought against it because they were worried that devs would only compile for Win32.

The trouble there is that Sun was right about that.

Doing it that way works great for open source where anyone can recompile the software for a new target, but for proprietary software they would have given you a Windows blob and that's about it.

Meanwhile the problems with Java were mostly not the JVM. Its current problem is, of course, Oracle.

The JVM and the ecosystem it sustains are more important than Java itself. The main reason newer languages can run "everywhere" is because hardware has been commoditized and the number of server OSes has been reduced to two. The JVM was designed to flatten a much more diverse environment than what we have today. Whatever you produce that can run on the JVM will still be runnable in 30 years.