I'd keep working while hunting for a new job. It's always nice to know you have a safe job to fall back on while negotiating with someone for a new position. It means that you can be picky and demand a higher salary than you usually would.
Generally speaking, I think pigeonholing yourself into one language or technology is a bad move. The technology is changing all the time, and Java isn't always going to be in demand. In my last 12 years at my company, I have gone from PHP, to C#, to C++, to Java, to Go. At some point it's not about the language, because languages are easy to pick up.
This sounds like a great chance to learn new things and grow in your career as a developer, rather than just staying in one specialization.
But if you really don't like the work they have for you, then that's reason enough to move on. Looking for a new job is always better when you don't immediately need it, so it can only help you to start now.
I doubt Java demand is going anywhere. Like with COBOL, I think the devs will eventually start retiring faster than the servers.
The fact that java isn't in vogue is only increasing long-term job security. Hordes of new devs are being trained up in javascript and python, but most of the world's financial, communication and administrative infrastructure has already been written in java. Nobody will bother rewriting most of it, because it works fine and it's not a frontier anymore. It will just require constant slow-burn maintenance for the next 50 years.
(I promise I'm not just trying to reassure myself; I haven't written java professionally for over a decade.)
COBOL is a good example, you can't just learn the language and expect the high paying job offers to pour in. If you can land a job, it can be good, but generally it's not the language you need to be proficient in, and more the entire legacy system.
But really the point isn't that Java will die, but more that programmers need to be adaptable. Sometimes you just won't find the jobs in your niche and you need to show you can do something else. Sometimes your methodology grows out of fashion and companies want to try something new. Sometimes, competition is just plain stiff and you need to demonstrate that you're good for whatever the next project will be.
For most of my job interviews, they were far less interested in my proficiency in a given language, and more interested in my understanding of the design concepts, or the technology we were trying to make use of.
But hey, if someone does manage a whole career in one language, it's a sweet spot to be in. I'm not knocking it, I just don't expect that to be typical.
I agree, I only commented because I think java is the most likely exception to the rule
I think the usual thing is to go somewhere else if you're dissatisfied there.
Ask Experienced Devs
Icon base by Delapouite under CC BY 3.0 with modifications to add a gradient