You should not base your career choice of being Java programmer or not solely on Java's popularity.
There are genuine good reasons to learn niche technologies especially if you like them more. I think if you genuinely like something you are much more likely to succeed in that field and it is better for you no matter the size of the field.
Choosing niche technology means you will have less options when changing jobs but, remember, you only need one good offer.
Here's my thought about Java:
Java development is for a specific type of programmer that will most likely work for large corporation and more often than not on some unsexy backend system.
Java is uniquely suited to be language of choice for the enterprise for many reasons which I will not go into right now.
These companies are currently extremely hungry for Java developers. This also means you will not only have no problem finding a job, you should be able to command good starting price compared to about anything else (except maybe React).
Java is becoming better work environment, not worse, with every passing year. It has excellent tooling (IntelliJ IDEA being in my mind best IDE in the world except for Emacs with Slime). Excellent frameworks and support libraries (Spring Framework + satellite frameworks). Excellent support and portability (if you can install Java in particular major version it WILL work). Excellent build systems (Gradle being my choice). And it is also quite efficient with resources if you do it correctly and don't make bad choices -- JVM is actually very fast and the only major drawback is startup speed and memory upkeep which are not an issue for typical enterprise service.
Major drawbacks:
It is not particularly good language in itself, but that's what I get for learning Lisp. It got a bit better recently (recently in this case is past few years).
It is suited to particular types of projects which tend to be unsexy, enterprise services. If you become Java developer you probably will not be working on games, on exciting IoT projects, beautiful UIs, AI, and other exotic stuff. You will be doing backend systems and hopefully be paid well.
Oh, and you will be working with a lot of people that barely can write a loop. That's that. I said it...