5

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.

Fildor
  • 14,510
  • 4
  • 35
  • 67
  • 1
    Is the jdk bin directory in your windows path? If not, add it, reboot, and try again. Also, check how Netbeans is started (parameters in shortcut, or the netbeans configuration file netbeans.conf) - specifically for --jdkhome type switches or parameters – JRL Dec 16 '11 at 15:59
  • I am afraid it is in the path. Thanks for the tips, will check that and post results after the weekend. Have a nice one, by the way :) – Fildor Dec 16 '11 at 16:01
  • 2
    Do you have any plugins installed? And tell Edith I said hello! – black panda Dec 16 '11 at 16:18
  • Save yourself the headaches and just reinstall NetBeans. That should take care of it, especially if you download a version that comes with a JDK. NetBeans version 7 is out anyway. The later versions pick up the settings of the earlier versions so the transition is seamless, and the old version isn't removed. – Paul Dec 16 '11 at 16:37
  • 1
    see if you have rt.jar on the classpath of the project (in the IDE). you may be missing the java runtime for some reason... – aishwarya Dec 17 '11 at 00:15
  • @Paul: I'm afraid, I do not have a choice. Company restrictions are, that I am to use Netbeans 6.9.1 with the given JDK and nothing else :( See, I am one of a team and I cannot just go and mess up the "uniform". I will try and reinstall (the same version) Netbeans anyway, just so I can say "I have tried that". – Fildor Dec 19 '11 at 07:51
  • @aishwara: I'll check that and report back, thanks to you. – Fildor Dec 19 '11 at 07:52

2 Answers2

3

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!

Fildor
  • 14,510
  • 4
  • 35
  • 67
2

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!

NorRen
  • 711
  • 2
  • 9
  • 22
  • Good hint, the Project was indeed imported. But the target JDK was installed, checked, double checked and working. – Fildor Apr 24 '14 at 16:52