Installed JOSM for Mac and it gave the error above. How to solve it?

Same here. From what I could gather, the launcher is supposed to check for a supported Java version and it seems that it only deems Oracle Java as “valid” and doesn’t work with OpenJDK.

So find an old installer for Oracle Java 8, e.g. from here: https://github.com/frekele/oracle-java/releases and after installing it, JOSM should work. Of course, this isn’t a long-term solution as Java 8 is quite old already.