neither java code nor binaries are very portable, despite the original marketing. wasm is essentially a binary format. You can certainly make a non-portable wasm just the same way you can make a non-portable elf binary. But you don't have to. You can make a wasm that is even more portable than any elf binary since it's independent of any platform.
java byte code may have been theoretically able to do the same, but the jvm ended up being too varied and there is no universal jvm environment the way there is a universal wasm environment. Browser extensions don't remove or modify the base, only add.
java isn't relevant, not because it couldn't be in theory, but because in reality, it's just not. Browsers never baked it in, it never became an open standard, etc, it's essentially no better than every other interpreted or compiled language. We could have a universal standard that's essentially bash, but we don't. We have bash, but it will never be a universal format the way wasm already is. Being baked into everyone's browser makes all the difference. When you want to publish a picture, tiff is a very versatile container and is better than most other formats, but the format you will actually use will be png or jpg etc, because even though many tiff viewers are available, they aren't built in to all browsers. It doesn't matter that tiff already existed and could do the same job. java is tiff.