简体   繁体   English

使用 JDK 13 编译并使用 JRE 8 运行

[英]Compile with JDK 13 and run with JRE 8

I compiled my program, but when i try to run it, i get this error :我编译了我的程序,但是当我尝试运行它时,出现此错误:

Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.UnsupportedClassVersionError: Lanceur has been compiled by a more recent version of the Java Runtime (class file version 57.0), this version of the J    ava Runtime only recognizes class file versions up to 52.0
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(Unknown Source)
    at java.security.SecureClassLoader.defineClass(Unknown Source)
    at java.net.URLClassLoader.defineClass(Unknown Source)
    at java.net.URLClassLoader.access$100(Unknown Source)
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)

I tried to "move" the JDK 13 all the way up in PATH, restarted my PC, but nothing changed.我试图在 PATH 中一直“移动”JDK 13,重新启动我的电脑,但没有任何改变。 Here is a screenshot :这是一个屏幕截图:

环境变量

I then tried to download JRE 13, but can't find it anywhere.然后我尝试下载 JRE 13,但在任何地方都找不到。

How can i do this ?我怎样才能做到这一点 ? I can't update to JDK 14 or up, because i need something that was removed in these versions我无法更新到 JDK 14 或更高版本,因为我需要在这些版本中删除的内容

As you're compiling without a build environment, you'll need to build with:当您在没有构建环境的情况下进行编译时,您需要使用以下内容进行构建:

javac -target 1.8 -source 1.8 MainClass.java

Java versioning is confusing but stick with 13 until you get used to it. Java 版本控制令人困惑,但在您习惯之前坚持使用 13。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM