How to ensure Java JDK and JRE match and how to make them match if they dont

大城市里の小女人 提交于 2019-12-24 10:55:45

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!