on ubuntu 20.04:
sudo apt install openjdk-11-jdk
As Joakim suggested in this comment here, the headless version was installed. I got the same error with ldd, the library missing.
It’s not a good idea to change your question in general, it’s better to search first and ask a new one if needed, with all specifics.
This may help you understand the possible cause of the second issue:
Desktop API is not supported on the current platform
I highly recommend to use a plain Ubuntu Linux installation if you want to use Linux, WSL is not the same and has specific issues that you will not encounter in Linux. If a dedicated install is not an option, try to look for generic issues. Expect differences in behavior with shells, docker and graphical related things, because those things are specifically implemented in certain ways for WSL.