[英]In NetBeans 12.0 I get the error cannot access java.lang
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.
我最近开始学习 Java,并且能够使用文本编辑器使用 .java 文件打印“hello world”。 That was when I decided to get an IDE and I downloaded NetBeans 12.0.
那时我决定购买 IDE,并下载了 NetBeans 12.0。 Once netbeans was ready, I clicked "new project" and chose "Java with Maven" and "Java application".
netbeans 准备就绪后,我单击“新项目”并选择“Java with Maven”和“Java 应用程序”。 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.
但是,在文件中的“package com.mycompany.qwerty”旁边有一个红色感叹号符号,它显示了行号。 When I put my mouse over it, it said "Cannot access java.lang Fatal error: unable to find package in classpath or bootclasspath".
当我将鼠标放在它上面时,它说“无法访问 java.lang 致命错误:无法在类路径或引导类路径中找到包”。 I have absolutely no idea how to fix this since I have never used NetBeans before.
我完全不知道如何解决这个问题,因为我以前从未使用过 NetBeans。 I have tried reinstalling netbeans several times and the same thing occurs.
我曾多次尝试重新安装 netbeans,但发生了同样的事情。 I have jdk 11.0.8 as well.
我也有 jdk 11.0.8。 How would I resolve this issue?
我将如何解决这个问题?
After reading sorifiend's comment, I looked up how to change the file path for jdk.在阅读了 sorifiend 的评论后,我查找了如何更改 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.
在名为 netbeans.conf 的文件中,名为 netbeans_jdkhome 的变量只是 /usr 之类的,我将其更改为 /usr/lib/jvm/java-1.11.0-openjdk-amd64(我有 linux),然后问题就完全解决了.
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.