Thanks, that fixed it. I used the Java uninstall tool and removed all versions of Java that I had, and then reinstalled the latest Java 8 64 bit, and it now works perfectly.
I'm trying to set up a server for 1.12.2, so I installed and ran the recommended installer, and started the vanilla server .jar that is included, which works perfectly. The problem occurs when I try to run the forge.(verson).jar, it gives me this error, and none of the files are installed.