问题
I have been trying to get my JDK and JRE to match for a couple hours now, but do not know what to do. Any help appreciated.
I've checked the versions and realized they are different. I have already installed the latest JDK but do not know how to change the JRE to match the JDK.
javac -version javac 12.0.1
java -version java version "1.8.0_211"
C:\Users\jacob\OneDrive\Desktop\Code>java Ah Error: A JNI error has occurred, please check your installation and try again Exception in thread "main" java.lang.UnsupportedClassVersionError: Ah has been compiled by a more recent version of the Java Runtime (class file version 56.0), this version of the Java Runtime only recognizes class file versions up to 52.0
I expect to be able to have the same versions so that my code will run, but it will not run.
回答1:
It means that the environment variable for javac ( java compiler ) is pointing to a different version compared to the environment variable for java( java run-time ) command.
Check this comment and set up the correct environment variables.
回答2:
Try uninstalling JRE and only install JDK. It worked for me.
来源:https://stackoverflow.com/questions/56008502/how-to-ensure-java-jdk-and-jre-match-and-how-to-make-them-match-if-they-dont