Friday, 8 April 2016

Netbeans - Background Scanning Optimization

Introduction :
People using NetBeans for Java development must have encountered the “Background scanning of projects...” message every now and then. This usually happens on opening the IDE, during project build operations or changing any resource used in an open project externally outside NetBeans.


Background scanning is quite essential and important otherwise some productivity features such as code completion, refactoring, go to definition, etc. which require a knowledge of the source code structure could not be used.


Problem Statement :
Unfortunately it is reported by many NetBeans users that the Background scanning of projects is quite slow and it takes too long to complete before the IDE is usable. This is valid for a range of NetBeans versions (NetBeans 6.x, 7.x, 8.x).


Scanning issues are the most commonly heard “deal-breakers” for the NetBeans IDE and the NetBeans forum is full with bug reports regarding this issue of slow Background scanning of projects and the bug fixes and corrective actions mentioned therein have not worked for me and also might not have worked for many other users as suggested in many Stackoverflow questions and comments.


Solution :
Today I am sharing with you a technique that worked for me in optimizing the Background scanning of projects (particularly large Java projects)


My configuration :
Operating system : Mac OS X Yosemite (version 10.10.5)
Processor : 2.2 GHz Intel Core i7
Memory : 16GB
NetBeans version : 8.0.2


Procedure :
1) In NetBeans IDE, go to Window-->Files. This opens the Files Tab.
2) In the Files Tab for each opened project open the nbproject folder and inside it open the project.properties file.
3) Now in this file below the property "excludes" there are file references listed for all your referred Libraries (JARs)
4) There might be some repeated file references with paths that may be old or on someone else's machine(if you are working in a group and transferred projects from someone's machine)
5) Delete those old path references.
Example -


excludes=
file.reference.xyz.jar=../not/correct/path.jar  //delete this line
file.reference.xyz.jar-1=../correct/path.jar    //remove -1
....
includes=**


6)Also locate the property "javac.classpath" and delete the unnecessary classpath entries corresponding to the deleted references as described above.
Example -


javac.classpath=\
${file.reference.xyz.jar}:\       //keep this line
${file.reference.xyz.jar-1}:\     //delete this line
....
javac.compilerargs=


7) So now the file reference mentioned in the file reference section and the javac.classpath property is same and points to a valid Library (JAR) address on your machine or network.
Example -


excludes=
file.reference.xyz.jar=../correct/path.jar//correct reference & path
....
includes=**
....
javac.classpath=\
${file.reference.xyz.jar}:\ //the correct classpath entry for reference
....
javac.compilerargs=
....


Reason :
The reason I faced the above issue was because my projects were transferred from many machines and had repeated references to many other machines and NetBeans was scanning for those unreachable paths.


Conclusion :
The above procedure works because it prevents NetBeans from scanning unnecessary Library paths that may not be present on your machine/network.

Hope this helps you in improving the background scanning performance of NetBeans.


2 comments:

  1. Thank very very very so much, i just delete all de jar ref and right click on the project node to solve the missing ref

    ReplyDelete
  2. after solving the missing ref i made a "clean and build" that's all id did to make netbeans stop scanning

    ReplyDelete

Enter ur comments