views:

1515

answers:

5

I created a Web application in Netbeans 6.5. Now I want to use the Joda Time library. I want to share this library via subversion, because I don't want my team mates to be dependend on some Netbeans configuration.

Just to get the project working, I first added the library to the Netbeans library (Tools->Library). This worked OK. The JAR is added to the classpath, and is also deployed.

But when I create a shared library (via Project Properties->Libraries->Browse/New Libraries Folder), the JAR is not in the classpath. I get the error message package org.joda.time does not exist on the code import org.joda.time.*.

Any ideas?

A: 

Here is what I did:

  • Tools -> Library -> New Library...

    • called the library joda-time
    • add added the joda-time-1.6.jar file to it
  • Project -> Properties -> Libraries

    • under the compile tab
      • Add library...
      • selected joda-time

(Edit, think I see the issue now - but perhaps not).

You need to add the library to the compile libraries AND add it to the distribution libraries. Or am I misunderstanding the question?

TofuBeer
I have added the library to the compile time tab. But when you do it like this, you can't share the library. Other team members have to add the library to their global library (tools->library), and I wanted to prevent just that.
doekman
A: 

This blog entry describes a hack that worked in NetBeans 5. I don't know if it will work in NetBeans 6.5. I also don't know if this will work if you are building files nightly on a server.

http://blogs.sun.com/gjmurphy/entry/using_netbeans_free-form_projects_as

I remember setting up shared libraries like this 8 years ago in JBuilder. I wish Netbeans had it by now.

sjbotha
+1  A: 

What is the scope of this library? Is this library used for just this particular web-application?

If so, can we put the library in the WEB-INF/lib directory and check that into subversion as well?

Libraries in the WEB-INF/lib directory should be automatically added to the classpath of the project.

lsiu
Libraries in WEB-INF/lib are not exposed at compile time, and that is just what I need..
doekman
A: 

when creating a 'new project', there is an option to enable 'dedicated folder for libraries'. That way, the libraries will also be committed to the repository and your peer developer can checkout your project with all the libraries, your project has dependencies upon, thereby eliminating netbeans configuration bound.

Vaibhav Bajpai
A: 

In scenario where a project depends on JARs which can be placed in different locations for different users, a named IDE variable can be used.

http://wiki.netbeans.org/NewAndNoteWorthyNB65#section-NewAndNoteWorthyNB65-VariableBasedPathsInJ2SEJ2EEProjects

Another option would be to use the Maven plugin which already works quite well in NetBeans 6.5. A Intranet repository for the Artifact Jar files could be placed on a file server, or managed through a Maven Proxy like Nexus.

mjustin