I work with both but maintaining a large backend in JS with a large team has made me really appreciate Java and all it’s uncoolness
With Java the code, dependency management, and build tools just work. It's very pleasant to maintain.
Maintaining a JS project over more than a few years is a nightmare. Forced rewrites as libraries, build tools, linters, frameworks, and the language itself are constantly being reinvented. It's a huge pointless drain on resources.
And JS is awful cross-platform. You have to check and polyfill every feature if you want to work outside latest Chrome and Firefox. And transpile the code down to ES5.
With Java it runs exactly the same on every platform. We develop on Macs and run on Linux and it doesn't even matter.