Getting Netbeans and Subversion to play together nicely with libraries?

I'm having a difficult time figuring out how to add a .jar/library to a Netbeans project in such a way that I can get it committed to the repository.

The typical way to add a library (per the Netbeans documents I've already gone through) ends up with it just being local to me. Anyone who checks out my project ends up missing my required library.

Inserting it manually and trying to work around Netbeans results in Netbeans hanging while trying to scan the project...

So, how can I tell Netbeans to pick up a jar as a library and include it in my project in such a way that Subversion will be able to handle it?

Asked by: Leonardo969 | Posted: 23-01-2022

Answer 1

There are a couple ways to fix this.

A. When you define your Library, use a path to a common location. A location that's identical on everyone's machine--such as the location of a JAR installed with a third-party app into Program Files or /usr/local/ works well or a network drive.

Then, when they check-out the code, the path will still be correct and they do not have to define the Library on their Netbeans workspace.

B. Edit your file to use a relative path. Open your file and look for "libs.LIBRARY_NAME.classpath=...". That will be the "default" location used if the Library is not defined.

Change this to use a path relative to your project and store the jar files in your project. For example: libs.Log4J.classpath=lib/log4j.jar

Keep in mind that the Library definition in your Library Manager will override this value--so make sure you keep them in-sync (i.e. append a version number to the library name!).

C. Use Vincent's suggestion of using a build-system such as Maven. The Maven build-process will take care of downloading dependencies, etc. Netbeans has plugins for several popular build systems.

Answered by: Arnold116 | Posted: 24-02-2022

Answer 2

There is a new feature in NetBeans 6.5 (variable-based paths in projects) which should make this easier.

See for details. Note the screenshot includes variable references in the library customizer.

Answered by: Elise226 | Posted: 24-02-2022

Answer 3

Not really an answer to your question but... generally you should not include these libraries in your subversion repository. There is usually no need to have them managed. What you might want is to set up a central repository similar to what happens with maven. If you use maven, you can create a local repository of libraries on a server accessible by the team. The dependencies on these libraries are entered in the pom.xml file and this is in the subversion repository. Now, as team members check out the code from subversion they all have access to the maven repository.

[I am looking for a reference to this right now. When I find it I'll edit this answer.]

Answered by: Freddie340 | Posted: 24-02-2022

Answer 4

I use NetBeans IDE 6.5.1 and the best solution I've found so far is to include the needed libraries from your local host and then change their paths to relative. After that you have to remove the libraries manually from the NetBeans file explorer, and then copy them from their OS location in your computer manually to the file explorer again. That way NetBeans detects the change and you can commit it to the repository.

Note: I Highly recommend to clean and build the project again after updating.

Answered by: Andrew649 | Posted: 24-02-2022

Answer 5

An easy way to pack up your lib/jars into your project so that subversion "just handles it" so you can grab it out with all the attached libraries ready to compile and go is to include them all under your project directory via the "shared libraries" option by managing the libraries folder.

When creating a new project you can specify "Use Dedicated Folder for Storing Libraries" and then use the suggested relative .\lib path. If you have an existing project, you can edit it's properties, Libraries Category, and Browse for a Libraries Folder. Again a first-time run will suggest .\lib and then offer to copy existing dependencies to that folder. These graphical actions should provide similar results to James Schek's 'B' answer.

Commit the project with the newly added libs in .\lib and you should be able to checkout and build from anywhere and know you'll have the same libs (at the same version) as you had when you last built and committed.

I don't know how long this feature has been in NetBeans. For more details see:

Answered by: Aston821 | Posted: 24-02-2022

Answer 6

I ended up just downloading my own set and putting them on my local drive for this project. I setup my Netbeans to look there and warned the other guys what I did... Eventually, we'll have to do something a bit more scalable though... :-)

Answered by: Leonardo306 | Posted: 24-02-2022

Answer 7

OK, the working solution that I've now moved to is to extract the class files out of the jars and dump them into the Source Packages area. Then it all gets committed to the repository and also avoids having to deal with handling a separate "lib" directory in the deployment phase.

This solution does everything I'm looking for, yet I feel real dirty about doing it this way. It just seems horribly broken and wrong... :-)

Answered by: Sophia781 | Posted: 24-02-2022

Similar questions

java - After checking out Subversion code into Eclipse, how do I get it to build?

This problem has been frustrating me for some time... A lot of sites like Sourceforge use SVN or Subversion to manage their code. I have little problem compiling SVN code in C++, but when it comes to Java, my IDE gives me a headache. I've installed Subclipse for SVN support for Eclipse, and it works. I can check out any code into my Workspace. Now Subclipse will put the whole thing into a special project of...

java - Can't commit to Subversion from NetBeans

When I change some interface things in Java, like the contents of a menu item, and save them, the commit option does not enable. NetBeans does not know that changes have been produced so I cannot commit them. How can I commit them?

java - Steps to "Mavenize" a Eclipse or NetBeans project with the help of Subversion?

The process of mavenizing Eclipse and NetBeans projects usually takes a lot of manual work, if all files are under revision control. So I am thinking of writing an Ant script which uses svn commands to rearrange the files in the working copy according the standard Maven directory layout. This would keep all file revision histories intact. If all files have been moved to the correct places, the new directory struct...

svn - does Java have API wrappers around subversion and Git?

Curious if there any API wrappers for Git and Subversion for Java? I want to be able to pullup the changesets and souce code (and diffs) from Subversion and Git repos. Is this possible? Any pre-built APIs?

java - which class/jar file in fisheye hooks into subversion and GIT?

which class/jar file in fisheye hooks into subversion and GIT? I want to use it to extend the functionality a bit.

svn - Is there a Java solution to svnserve like svnkit is to subversion in Java?

Is there a Java solution to svnserve like svnkit is to subversion in Java?

eclipse - How to rename Java packages without breaking Subversion history?

The company I'm working for is starting up and they changed their name in the process. So we still use the package name com.oldname because we are afraid of breaking the file change history, or the ancestry links between versions, or whatever we could break (I don't think I use the right terms, but you get the concept). We use: Eclipse, TortoiseSVN, Subversion I found

java - Add a new file in Intellij doesn't add to subversion

I'm not sure what I did to cause this, but adding a new file or package in IntelliJ now doesn't add them to subversion, and I have to add them manually via right-click -> subverion -> add. Is there a setting that controls this behaviour?

java - Add subversion revision to war manifest using maven2

I want to find a maven native (i.e. without calling external programs) to inject the svn revision in the war manifest. Does anybody know a way to do that? I found mention to how to add the subversion revision to manifests in jar files but not with war files. I searched SO but could not find this issue specifically.

java - How do I start a new project in Eclipse and Subversion

A newbie question (I haven't really created new projects in Eclipse yet): I have a machine running Linux with a fresh install of Eclipse 3.5.2. I want to create a new Java project in an existing subversion repository (which already contains some unrelated stuff). So after running Eclipse I get this dialog to specify workspace. What is the best practise here? Should it be in subversion? Then when I created a random one, whe...

Still can't find your answer? Check out these amazing Java communities for help...

Java Reddit Community | Java Help Reddit Community | Java Community | Java Discord | Java Programmers (Facebook) | Java developers (Facebook)