I've tried the java version you linked to and got a new exit code of 127
Here is the new console log
I also tried making sure that I had Java 8 selected with the version of Java 8 I already had installed and got the same exit code
Here is the console log with that installation in case it has any differences
I do notice both say 'Java checker returned some invalid data we don't understand:' followed by 'Minecraft might not start properly.' which could be some issues.
Of the newer versions I have tested, 1.21.5 does work perfectly fine, but the only others I have tried, being 1.12.2 and now 1.16.5 with the mods you suggested showing the same results of crashing with exit code 6.
I tried both Vanilla and Optfine like you said, and both gave the same result. So I believe the issue is most likely with Minecraft in general and not Forge
I've been trying to use Forge for a 1.12.2 mod using the Prism Launcher and I've been getting crashes with exit code 6.
The console log is this.
I've tried running Optifine as a test mod and I have tried running with no mods, but both gave the same result.