I have a problem with my code, even though it hasn't been modified in any way. It just suddenly threw this message. As you can see on the left, that they are all in the correct package, and have correct names.
What can I do to fix this problem?

- 2,805
- 10
- 32
- 38

- 73
- 1
- 1
- 7
-
2Try cleaning and rebuilding the problem. Eclipse, and I assume netBeans gets confused periodically. – DwB Feb 12 '16 at 11:22
-
Right click on project then select clean and build....then try – Piyush Gupta Feb 12 '16 at 11:25
-
The option to clean and rebuild in the Tools drop down menu is greyed out, it won't allow me to. – user5903893 Feb 12 '16 at 11:33
4 Answers
Clear the cache to fix it. In Windows, cache is located at:
C:\Users\username\AppData\Local\NetBeans\...
On Linux, cache is at:
/home/username/.cache/netbeans/...
After clearing the cache restart netbeans.

- 1
- 1

- 9,199
- 8
- 48
- 62
-
3on Mac OS on ~/Library/Caches/NetBeans/${netbeans_version}/ For this kind of problem it is enough to delete the subfolder ./index/ only. – Benedikt S. Vogler Feb 12 '16 at 11:49
If clearing the cache still doesn't work try adding the jar files themselves instead of adding the folder. Looks like a bug in Netbeans. I did it that way and worked like a charm.
I had some compiled classes from a JAR which I wanted to include in my project. I created a new package, I added the complied classes in and then got this "package does not exist" error when trying to import the new package.
If you're adding compiled Java classes and getting this error, here's how I solved it:
Create the package
Add a new (empty) Java Class (.java file) to the package, using the same name as the compiled Java class.
At this point, you should see your broken references to "package does not exist" or to the class file you just added are fixed.
Delete the new .java file and NetBeans should still see the package with the newly added classes.
I ran into this problem after we moved our NFS mount point containing my root project directory.
It seems there were some references to the old mount point in the .nb-gradle
directory.
I closed all the projects in Netbeans and terminated Netbeans. I moved .nb-gradle
to hidden.nb-gradle
(and .nb-gradle-properties to hidden.nb-gradle-properties for good measure). I restarted NetBeans and reopened the root project (which auto-opened the subprojects).
The does not exist
message and all cascaded errors went away. A new .nb-gradle
directory was created in the root project directory. The .nb-gradle-properties
file was not re-created.

- 2,422
- 5
- 28
- 41