Tim B
Tim B

Reputation: 41188

Is there an easy way to copy libraries between projects on netbeans?

Often I find that I have a set of JAR files configured as libraries in one Netbeans project and I need the same (or a subset of) those JAR files in another project.

All of the ways I've found to do this so far are very long winded and painful so I am hoping I've missed something simple.

Google found a 6 year old feature request and nothing else really useful: https://netbeans.org/bugzilla/show_bug.cgi?id=118325

At the moment the ways I can think of are:

Create a "Library" for the set of JARS and then use that library in each project. This is probably the neatest way to do this but still involves a lot of steps and seems like massive overkill just to copy a few JAR file references!

Go to source project, right click JAR, select edit. See the library classpath in the popup window. Close window, go to the destination, select add JAR. Can't cut and paste in path so have to hope you remembered it right. Browse to JAR file, add it - repeat for any other JARs that are not in the same folder.

Frustratingly the tooltip that comes up when you hover over the library contains exactly the path you need to add the jar - but there is no way I can find to copy the contents of that tooltip!

This is all made much more painful by the fact that all the windows are modal, you can't cut and paste the path out because it doesn't actually copy as a real path, etc.

All suggestions welcome as this is becoming a frequent annoyance at the moment!

Upvotes: 1

Views: 1968

Answers (1)

brian
brian

Reputation: 10979

I just found this old question while searching for an answer to the same problem. I Couldn't find any other useful results so I copied the libraries in the nbproject/project.properties file to the same place in my new project.

The only references I found in the whole directory were like this

file.reference.commons-lang3-3.8.1.jar=D:\\Documents\\javaLibraries\\commons-lang\\commons-lang3-3.8.1\\commons-lang3-3.8.1.jar
file.reference. [.....many more]
includes=**
jar.compress=false
javac.classpath=\
    ${file.reference.commons-lang3-3.8.1.jar}:\
    [....many more]:\

This part was just in between what I wanted, so I copied the whole thing but it was the same in the new project.

includes=**
jar.compress=false

So far it's all working fine. You could back up the project.properties file but I already had one nightly.

edit: You can also copy over the javadoc and sources by copying the lines like

javadoc.reference.commons-lang3-3.8.1.jar=D:\\Documents[more path....]javadoc.jar
source.reference.commons-lang3-3.8.1.jar=D:\\Documents[more path....]sources.jar

Upvotes: 1

Related Questions