I do not know about the NetBeans; however, the way I solved this kind of issue is as follows:
1) From the directory where the custom java file is, put all the pi4j jar file in the directory.
2) From the same directory, type "sudo java -cp .:* filename.java"
3) If the same error message occurs, then goto GitHub to get the pi4j source code and investigate.
4) Or compile the pi4j source code, along with your custom source code, inside your NetBeans ide and debug it.
Good luck!