Actually, it is up-to-date (new features twice a year, some of them, e.g. virtual threads, are truly SotA) and not legacy (things like graalvm and helidon 4 are relatively new and are awesome). Do not avoid Java if your project would benefit from it.
Almost no new project would benefit from Java. Android apps should use Kotlin.
Avoid JVM for new projects unless there is no other way.