Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"cannot access java.lang" - Error in Netbeans 6.9.1

This is driving me crazy:

In Netbeans (6.9.1 on a 64bit Windows 7) with JDK 6 correctly installed, the Editor shows this Error at package my.package.name:

cannot access java.lang
Fatal Error: Unable to find package java.lang in classpath or bootclasspath

The Project compiles just fine, it is just the Editor messing up. Other projects in the same IDE work just fine. Other types of Projects (the errornous is a J2SE Project) work fine.

I tried to Google this, but there are always solutions about that the JDK was not installed right or links to it were corrupt in the project files. This is not the case here. I double and tripple checked the JDK installation: it is ok. Other projects do not show that behaviour in the very same IDE and are using the same JDK.

I diff'ed the project files against correct working project files and could not see any major differences except from those that are expected to be there.

I tried to delete the project and make a new one with existing sources. This works at first glance but once I close the IDE and open it again the same failure will show up.

I tried to revert from SVN to an older version of the project files before this happened: no chance.

In all files of that project I have that error and of course a lot of "cannot find symbol", which prevents also autocomplete and everything.

Does anyone know why this happens and how I can make it stop? It is really more than annoying and I cannot just switch to Eclipse (not my decision).

Any attempt to help will be highly appreciated!

P.S.: Edith just reminded me to tell you that I did not try to reinstall Netbeans since I read in one of the articles I found through Google that it will not help.

Update
This is from netbeans.conf:

netbeans_jdkhome="C:\Program Files\Java\jdk1.6.0_27"

And it is the only JDK I have so this should be perfectly correct.

Update 2
Loads of Plugins: Ada, Android, Ant, Bundeled Subversion Client for Windows, C/C++, Database, EJB and EAR, GUI Builder, Hibernate, Hudson, IDE Branding, Identity Management, IDE Platform, Java, Java -Debugger, -Persistence, -Profiler, -Web Applications, JSF, Local History, Maven, Mercurial, Mobility, Netbeans Plugin Development, RCP Platform, RESTful Web Services, soupUI WebService Testing, SOAP Web Services, SOftware as a Service, Spellchecker, - English DIctionaries, Spring Beans, Spring Web MVC, Struts, Subversion, Team.

Update 3
Checked rt.jar: It is on the bootclasspath, build.properties has

platforms.JDK_1.6.bootclasspath=....${platforms.JDK_1.6.home}\\jre\\lib\\rt.jar;...

Reinstalling Netbeans did not change anything.
@JRL : No commandline switches are used.

like image 294
Fildor Avatar asked Oct 09 '22 05:10

Fildor


2 Answers

Ok, I do not know why it worked, but it worked:

  1. I closed Netbeans
  2. I navigated to "C:\Users\MyUser.netbeans\6.9\var"
  3. I renamed the folder "cache"
  4. Restarted Netbeans
  5. Profit?

Somehow this folder was still present after reinstallation. Got that tip from a colleague. He neither knows the exact reason why this behaviour pops up nor why it goes away when you force Netbeans to recreate "cache". But it works.

Thanks a lot to all of you for trying to help me!

like image 195
Fildor Avatar answered Oct 13 '22 11:10

Fildor


If this error occures for an imported project, then one might miss the Target-JDK for this project.

In the Project Explorer right-click the affected project and select Properties. Now go to section "Libraries". As you see in the screenshot, JDK 1.6 has been selected for that project but this JDK is not available on the current machine.

Project Properties Screenshot

Solution:

Install the needed JDK and add it via the "Manage Platforms..." Dialoge in the Project Properties or check if the project is compatible to an installed JDK. To do so, select an installed JDK from the Java Platform Dropdown and try to compile the project. Note that the latter solution might lead to errors or unexpected behaviour!

like image 44
NorRen Avatar answered Oct 13 '22 12:10

NorRen