Part of what kept Java afloat despite the rise of JS is its platform Java Virtual Machine. The "write once, run anywhere" principle of Java made it a versatile and universally compatible language as long as the device has a Java Runtime Environment.
This important feature made it the best language to use for developing mobile applications. In fact, it’s the official language for Android development and is supported by Android Studio. Around a fourth of the apps currently in the Google Play Store are made with Java and its frameworks.