Java's focus on cross-platform support from the start probably seemed like a waste of resources back in the 1990s when Windows was so dominant, but it had the advantage of making it more popular amongst UNIX users and the existing open source culture. Java going open source long before .NET also contributed to this. The end result is that you get organisations like Red Hat, Apache, IBM that create vast quantities of high quality open source Java code, and a culture that is steeped in open source development. Whereas in .NET it's rare to use components not built by Microsoft and when they do exist they are typically proprietary, same as in the 1990s.
This doesn't seem to be a complete explanation. I was doing Java heavily in the early 2000s, and open source Java was pretty new still. Apache Struts[1] was possibly the first big OS Java project, and it was only released in 2000. The first version of .NET was released in 2002, and something like Rails was only released in 2004.
"Head start" doesn't seem to explain this.
There must be a reason for this though, one of the reasons why Java has a good ecosystem is because it's had a huge head start in terms of time and mindshare.
At the same time though, what's stopping people from making the open source ecosystem in .NET really good? There must be a reason, is it cultural?