(EN) Libraries in J2SE project
By jara on II 26, 2007
In the past I have been solving problems connected to moving my own Java J2SE project from one computer to another. The problem is with projects that use libraries. I was sometimes very upset when I was opening project containing some Matisse forms. Those forms depend on .jar file like swing-layout-1.0.1.jar. Unfortunately this .jar file was not available in JDK<6 so that this library was referenced from NetBeans IDE subfolder. This is managed by nbproject/project.properties where each such library is defined as a relative path to the proper .jar file. The line with such definition looks like following:
As a workaround for this I usually created some JFrame Form that I immediately deleted. By this trick I just attached another swing-layout library to the project (that one from the currently used NetBeans IDE).
The example above has a general pattern. Imagine that your project uses some .jar file located anywhere on you harddisk. There is no possibility to use previous fake. Because it is possible that you don't have the same library on your other computer (you are moving your project from computer A to computer B). The only way is to have this library somehow contained in the project directory. Because this is the only thing (the only folder) you are going to copy from computer A to Computer B.
I personally use following solution for this problem:
First of all imagine we have project PRJ that needs to use library LIB.jar
1.Create folder PRJ/lib (it is not mandatory to call it 'lib')
2.Copy the LIB.jar to PRJ/lib
3.In Project Properties select Libraries node
4.By pushing Add JAR/Folder button add the PRJ/lib/LIB.jar as a library
I am happy with this concept and I hope it can help you to resolve similar situation when using NetBeans IDE.