在 NetBeans 12.0 中,我遇到了错误:无法访问 java.lang。

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

In NetBeans 12.0 I get the error cannot access java.lang

问题

我知道有很多类似的问题,但我尝试了各种方法,仍然不知道该怎么办。我最近开始学习Java,只能使用文本编辑器打印出“hello world”。那时候我决定获取一个集成开发环境(IDE),于是我下载了NetBeans 12.0。一旦NetBeans准备就绪,我点击了“新项目”,然后选择了“Java with Maven”和“Java application”。设置好项目后,我右键点击了包并创建了一个新的主类。然而,在文件中“package com.mycompany.qwerty”的旁边,显示行号的地方出现了一个红色的感叹号符号。当我把鼠标悬停在上面时,它显示“无法访问java.lang 致命错误:无法在类路径或引导类路径中找到包”。因为我以前从未使用过NetBeans,所以我完全不知道如何解决这个问题。我已经尝试多次重新安装NetBeans,但问题仍然存在。我也安装了jdk 11.0.8。我该如何解决这个问题?

英文:

I know there are very many questions exactly like this, but I have tried various things and still have no idea what to do. I started learning java very recently and was just able to print "hello world" with a .java file using a text editor. That was when I decided to get an IDE and I downloaded NetBeans 12.0. Once netbeans was ready, I clicked "new project" and chose "Java with Maven" and "Java application". Once I finished setting up the project, I right clicked the package and made a new main class. However, next to "package com.mycompany.qwerty" in the file there was a red exclamation mark symbol where it shows the line numbers. When I put my mouse over it, it said "Cannot access java.lang Fatal error: unable to find package in classpath or bootclasspath". I have absolutely no idea how to fix this since I have never used NetBeans before. I have tried reinstalling netbeans several times and the same thing occurs. I have jdk 11.0.8 as well. How would I resolve this issue?

答案1

得分: 2

在阅读sorifiend的评论后,我查找了如何更改jdk的文件路径。在一个名为netbeans.conf的文件中,变量名为netbeans_jdkhome的值只是/usr或其他什么东西,我将其更改为/usr/lib/jvm/java-1.11.0-openjdk-amd64(我使用的是Linux),然后问题完全解决了。

英文:

After reading sorifiend's comment, I looked up how to change the file path for jdk. In a file called netbeans.conf the variable called netbeans_jdkhome was just /usr or something and I changed it to /usr/lib/jvm/java-1.11.0-openjdk-amd64 (I have linux) and then the problem was completely fixed.

huangapple
  • 本文由 发表于 2020年8月27日 10:13:10
  • 转载请务必保留本文链接:https://go.coder-hub.com/63608156.html
匿名

发表评论

匿名网友

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

确定