如何在Eclipse中修复尝试构建和运行简单程序时出现的启动LinkageError?

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

How to fix launch LinkageError in Eclipse when trying to build and run the simple program?

问题

我在过去的几个小时里一直在尝试配置Eclipse IDE并使其工作,但我无法找出问题出在哪里。

我尝试了在IDE内部更改许多设置,但仍然无法使其工作并编译程序。
我想安装的Java版本是Java SE 15。

我该如何解决这个问题?

在尝试构建简单的控制台程序时,我遇到了以下错误:

错误:加载主类org.sun.dem15时发生LinkageError
java.lang.UnsupportedClassVersionError: 不支持对org/sun/dem15(类文件版本59.65535)使用预览功能。请尝试使用'--enable-preview'运行。

问题更新:

在进行以下更改后:

项目 ---> 属性 ----> Java编译器,并使用--release选项以及启用Java 15的预览功能,我得到了下一个错误:

构建过程中发生错误。
在项目“demo”上运行构建器“Java Builder”时出错。
未找到提供程序“jar”。

英文:

I've been trying for the past couple of hours to configure Eclipse IDE and get it work, but I am not able to find out what is wrong.

I've been trying to change many settings inside of IDE but I was still unable to make it work and compile the program.
My wanted Java version to install is Java SE 15.

How can I resolve this?

While trying to build simple console program I am getting following error:

Error: LinkageError occurred while loading main class org.sun.dem15
	java.lang.UnsupportedClassVersionError: Preview features are not enabled for org/sun/dem15 (class file version 59.65535). Try running with '--enable-preview'

UPDATE OF THE QUESTION:

After making changes to:

Project ---> Properties ----> Java Compiler and using --release option and enabling preview feature for Java 15 I got next error:

Errors occurred during the build.
Errors running builder 'Java Builder' on project 'demo'.
Provider "jar" not found

答案1

得分: 0

我认为问题在于您在一个版本的Java中编译程序,然后在另一个版本中运行它。我建议您彻底卸载Java,然后重新安装最新版本。

按下Windows键,输入"add or remove programs"。搜索Java并卸载它。然后前往Oracle重新安装Java,并按照那里的说明进行操作。您可能会在这里找到更多信息:https://stackoverflow.com/questions/55447687/how-to-fix-java-lang-unsupportedclassversionerror-test-class-file-version-52-6

英文:

I think the issue is that you're compiling the program in 1 version of java and running it in another. I would recommend uninstalling java altogether and reinstalling the latest version.

Press windows key, type in add or remove programs. search for java and uninstall it. Then go to oracle to reinstall java and follow the directions there. You may find more info here: https://stackoverflow.com/questions/55447687/how-to-fix-java-lang-unsupportedclassversionerror-test-class-file-version-52-6

答案2

得分: 0

所以,问题实际上是世界上最愚蠢的事情!而且是我绝对不会怀疑的事情。
不知何故,Java SE 15 出了问题,它“没有”安装在计算机上,尽管我在“Program Files”目录中有一个包含所有Java文件的目录(甚至Java都没有安装)...

您实际上可以通过进入命令提示符并键入以下内容来检查:

java -info

如果您看到:

'java' 不是内部或外部命令,也不是可运行的程序或批处理文件

那么问题就是您的Java文件没有安装。

此外,还有一个命令 javac -info,如果您在控制台中看到相同的输出,那么您仍然没有安装Java SE。

英文:

So, the problem was the most stupid thing in the world actually! And thing I would never suspect.
Somehow Java SE 15 got problem, it "wasn't" installed on computer, even though I had directory in Program files which included all Java files(even the java wasn't installed)...

So you can check this actually by going into command prompt and typing: java -info and if you get:

'java' is not recognized as an internal or external command,
operable program or batch file

than the problem is your Java file isn't installed.

Also there's command javac -info and if you get same thing printed out in console still you don't have java se installed.

huangapple
  • 本文由 发表于 2020年10月28日 04:34:30
  • 转载请务必保留本文链接:https://go.coder-hub.com/64562508.html
匿名

发表评论

匿名网友

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

确定