C# is a better language over all. Java has suffered for a variety of reasons:
- An insistence on backward compatibility, which is why, for example, generics are kinda half-assed, the standard library has lots of gotchas as functionality was grafted on poorly.
- Apparent confusion of "slowly" with "carefully" which means many features are missing decades later, and what finally gets in there seems to be half a solution, as if the Java team wants to see whether it works before finishing it. The "AutoCloseable" try-with-resources thing seems a classic example (as well as hampered by the compatibility obsession)
- Oracle just doesn't seem interested in it as a project to invest resources into improving
- Oracle keeps playing licensing games which is pushing away a sizable amount of the community- especially that part they need to attract, skilled academics and other experts who aren't going to contribute to a proprietary project outside of being hired to work on it.
And... hate to say it, but Microsoft does know what it's doing for the most part.
But if truth be told, while they're not full replacements (JVM and .NET are far more useful than Slashdot's naysayers like to pretend), most of the mindshare lost from Java is going to Rust and Go. Rust solves a specific issue the JVM has, albiet with its own problems and requiring a mindset change from programmers, and Go is more Java-like but loses the bureaucracy overheads and compiles to executables directly.
Should you choose Java for your next project? If you're familiar with Java, and/or more comfortable programming in it than C# take a look at Go. If you need something more cross platform or something more modular, making Java and .NET the only platforms you'd look at, C# is way more advanced than Java ever will be.
Not trying to say Java is bad. It's just fallen behind, and Oracle sucks.