Meow
Meow

Reputation: 19071

How to set reference to the folder which contains multiple jar files?

My environment:

Netbean 6.9.1
Glassfish 3.0.1
Windows 7

Goal:

When my coworkers opens the Netbean Project, the library is already referenced without them manually create library, adding jars into it and reference it.

Detail:

I created Netbean project and the project has reference to few jar files in the folder. Currently whoever opens the project for the first time, they have to manually create library and refer it to the project.

My project location:

C:\Users\masatosan\Desktop\myProject\myApp

My library location:

C:\Users\masatosan\Desktop\myProject\lib\myLib

The myLib folder contains:

some1.jar
some2.jar
some3.jar

I can achieve my goal if I create reference to individual jar file by defining to project.properties file like below: (creating reference to sqljdbc4.jar)

file.reference.sqljdbc4.jar=../lib/sqljdbc4.jar
javac.classpath=\
    ${libs.restlib_gfv3ee6.classpath}:\
    ${file.reference.sqljdbc4.jar}:

But my case is different since I have 3 jars in the myLib folder and wanting to reference them all.

Is it possible to reference all jars in myLib folder?

Please let me know if you need more clarification.

Upvotes: 4

Views: 4599

Answers (2)

Meow
Meow

Reputation: 19071

I figured how so let me share.

  1. Tool --> Library then library window pop up.

  2. Create library called "MyLib" which contains multiple jars.

  3. Add "MyLib" to your project. This change will be written to project.properties file under nbproject folder.

project.properties file indicates the classpath of lib reference you just added.

It should look like something below

javac.classpath=\
${libs.Excella.classpath}:\
${libs.MyLib.classpath}

Now someone else opens the project from different machine and she just needs to do step#1 and #2, which is to create library with same library name i.e. "MyLib"

I think this is what Bill was saying originally but thought it would be helpful to give step by step instructions since I finally figured .... after long time :D

Upvotes: 2

BillRobertson42
BillRobertson42

Reputation: 12883

I'm sorry, but it doesn't work that way. When you create a project, you have to add the jar files individually.

However, if you put your lib folder under your project, netbeans will refer to them via relative paths. Then when you share the project (lib directory included), netbeans will be able to automatically find the jar files when the next person uses the project. That way you only have to add jar files once.

Short of using a dependency management tool like maven (which Netbeans has good support for), this is really the best solution. It uses a bit more disk space (obviously), but that's never been a huge issue for me.

Upvotes: 4

Related Questions