(EN) Libraries in J2SE project


English flag 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:
libs.swing-layout.classpath=../../../../space/60/netbeans/platform7/modules/ext/swing-layout-1.0.1.jar

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.
Comments:

Hey!

We have a JEE solution with _lots_ of projects.. What we do is to have a simple project that holds all the libraries and then we just referenciate the library from the common project.

This works fine beacause the "subprojects" (WAR,EJB,...) are all inside the EAR project folder! ;)

Posted by Luis SAntos on únor 26, 2007 at 05:22 dop. CET #

Post a Comment:
  • HTML Syntax: NOT allowed
About

jara

Search

Archives
« duben 2014
PoÚtStČtSoNe
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
    
       
Today