Java is hot garbage
But it is just the latest in a long series of languages that had their day in the sun and outlived their glory days.
Java it a hot mess, but it was replacing Visual Basic in many of the places it was being deployed in businesses. Visual Basic was pushing out old COBOL code. Each was deeply flawed in some ways, but those flaws were the things we didn't intend or know we needed to fix most of the time.
COBOL took over the business world because it was vaguely intelligible, and reasonably portable across (radically) different hardware architectures. VB used more modern programming and syntactic structures and brought deep Windows integration during the age it was the center of the universe. It was also a dumpster fire, so Java seemed an improvement at the time for enterprise software, and was under Sun's stewardship at least fairly cross platform.
It was also deeply wacky, and always came off like something that crawled out from under the sofa of an alternative lifestyle club. Strict and scolding, delighting in tying the hands of it's developers. It was also a dumpster fire of software quality and reliability. It's strict garbage collection meant that performance intensive code was crippled, hugely bloated and to often unstable.
So now we see that like so many others, it is in the twilight of it's era, as large scale projects move to platforms that actually deliver memory safety, instead of tying programmers hands while constantly blowing it's security promises from JVM bugs the average Java programmer had no control over, bugs that often gave over root to the underlying hardware, not just the data the programmer had access to.
Python will be the next on the list, displacing Java not because it fixed Java's failings, but because it was the center of the universe for big data and early machine learning research. It will last long after the AI bubble bursts, and by then Rust may take and hold the crown for a while, or maybe something else. But the research bears out that the success and popularity of computer languages is only loosely coupled to the technical aspects of them. They are driven by broader external trends as much as anything.
They also tend to last decades past their prime, because refactoring code is expensive and provides not new functionality while introducing bugs. For many companies it's too tempting to pile on technical debt instead of re-achitecting until the system is on the verge of collapse.