.JARa's Bilingual Weblog

Life's better with NetBeans
photo of Jara

(EN) Libraries in J2SE project ( 20070226 Pondělí únor 26, 2007 )
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.
Posted by jara ( II 26 2007, 12:49:09 odp. CET ) Permalink Comments [1]


Trackback URL: http://blogs.sun.com/jara/entry/en_libraries_in_j2se_project
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 01:22 odp. CET #

Post a Comment:

Name:
E-Mail:
URL:

Your Comment:

HTML Syntax: NOT allowed
Archives
Search
Contact
Links
Visits map
Referrers

   Disclaimer: This blog contains my own opinions which may differ from viewpoints of Sun Microsystems.