With only 40K of available RAM after enabling networking, it HIGHLY unlikely we will find a JVM that will fit in that space. With ESP32 and more RAM, it may become more possible. You'll likely need to balance your needs ... programming in C on a tight space with low power and WiFi ... or a Pi Zero with lots and lots of capacity including JVM but the need to add a $3 WiFi dongle and more power consumption.
there is actualy even a JVM for the AVR µC that needs only 256 Byte(!) of Ram...There are also a lot of other JVM for
embedded Systems, and while i could not find one that states that it is specifically suitable for the ESP i am sure
there is one which can be compiled with little to no effort for the ESP.
Of cousre i could start a Trial and Error thing, but i think it is more wise to ask for someone
who has already done it, or who can at least give me the right directions.