Project with sharable libraries (AKA How to avoid broken references)
By Tomas Musil on III 14, 2008
If you tried to share with someone your NetBeans project, where you depend on some libraries that you've defined in IDE, you probably received complains: "Your project does not work for me, I've got there broken references, everything's red underlined,.....and...I don't have time to do some tweaking, resolving...ummmm....maybe I'm not so interested in your project..:-)" Well, that's because your friend's IDE was missing definitions of libraries, that your project needs to work.Since now:
If you share your NetBeans project (e.g. using VCS), your friend just simply checks out your project and libraries with their definitions. Project is then ready to use out of the box.
Example of typical workflow:
- Create you project under some versioned folder. When creating project, don't forget to check Project Shared With Other Users checkbox. Do not change location for sharable libraries, it's good to have them on the same level as project folder(s).
- Add dependencies on libraries that your project needs. Notice that when you invoke Add library on your project, you are operating with shared libraries (i.e. libraries stored in location you defined), not global libraries. Good practice is that when you are adding new library into shared location, choose that you want to copy library JAR(s) into shared location. It ensures that definitions and JARs are physically at the same location.
- Once you do some coding, it's time to check in your sources into VCS. Notice that also newly added libraries are offered for commit.
- That's it! If someone checks out your project (as well as libraries folder as location for shared libraries), project is ready to use out of the box.
TIP: If you have some projects created by NetBeans 6.0 and you want to make them sharable, there's a wizard which can make project to use sharable libraries. Just go to project properties, and on Libraries panel you'll see Make sharable... button. This button triggers a wizard, which switches your project into sharable concept and imports necessary libraries to your shared location.