如何在Windows上安装了JDK和JRE的情况下运行Java代码?

huangapple go评论74阅读模式
英文:

how can I run Java code while i have JDK and JRE installed on windows?

问题

Sure, here's the translated content:

我是Java编程的新手,现在正在测试一个用于测试的HelloWorld代码。我在控制台文件夹中使用命令javac HelloWorld.java,它会创建一个文件HelloWorld.class。当我运行命令java HelloWorld时,我得到以下错误:

> 错误:发生了JNI错误,请检查您的安装并重试
主线程中的异常"main" java.lang.UnsupportedClassVersionError: HelloWorld已由更新版本的Java Runtime编译(类文件版本58.0),而此版本的Java Runtime仅识别高达52.0的类文件版本...

我必须提到我已经安装了JDK 14.0.2和JRE(用于Minecraft和服务器 :))。

英文:

I am new in java programming and now i am testing a helloworld code to test. I use the command
javac HelloWorld.java in the console folder it's create a file HelloWorld.class . When i am running the command java HelloWorld i get

> Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.UnsupportedClassVersionError: HelloWorld has been compiled by a more recent version of the Java Runtime (class file version 58.0), this version of the Java Runtime only recognizes class file versions up to 52.0 ...

I have to mention that i have JDK 14.0.2 installed and JRE ( for minecraft and server 如何在Windows上安装了JDK和JRE的情况下运行Java代码? )

答案1

得分: 1

不要运行 java HelloWorld.Java,而是运行 java HelloWorld,即不带 .java 扩展名。

英文:

Don't run java HelloWorld.Java instead
Run java HelloWorld ie without .java extensions.

huangapple
  • 本文由 发表于 2020年8月29日 07:15:58
  • 转载请务必保留本文链接:https://go.coder-hub.com/63641940.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定