PDA

View Full Version : NetBeans project JAR dependency chain management




wrldwzrd89
Jul 26, 2008, 12:08 PM
ARRGH, this is driving me bonkers. I'm trying to create a NetBeans project that depends on another NetBeans project, that depends on an external JAR. However, I cannot get the first project to run. All projects compile properly, but the first project cannot see the JAR file the second project references, for some reason. :confused:



lee1210
Jul 26, 2008, 12:20 PM
Check the manifest.mf under meta-inf in your primary projects jar file, and see where it is expecting its dependencies to be. I think by default it is in a subdirectory called lib. So if you have myproject.jar in your home directory, you would need to have a subdirectory called lib that has all third party libraries as well as the jar file for your project.

-Lee

wrldwzrd89
Jul 26, 2008, 12:26 PM
Check the manifest.mf under meta-inf in your primary projects jar file, and see where it is expecting its dependencies to be. I think by default it is in a subdirectory called lib. So if you have myproject.jar in your home directory, you would need to have a subdirectory called lib that has all third party libraries as well as the jar file for your project.

-Lee
You are correct - it is looking in a folder called lib, inside the dist folder. However, I wish there was a way to auto-propagate referenced JARs in one project to other projects that use that project - this would be ideal, and would make things work properly.

As things are right now, even if I manually copy the JAR files to the dist/lib folder of the main project, it won't find them.

lee1210
Jul 26, 2008, 12:31 PM
You are correct - it is looking in a folder called lib, inside the dist folder. However, I wish there was a way to auto-propagate referenced JARs in one project to other projects that use that project - this would be ideal, and would make things work properly.

As things are right now, even if I manually copy the JAR files to the dist/lib folder of the main project, it won't find them.

My approach when I was using NetBeans was to add the jar from the dependencies dist directory to the depending project. Then, when you do a build of the depending project, it should copy that jar to the dist directory.

As long as /lib is in manifest.mf in the CLASS-PATH line, it should pick up your jar if you put it there.

-Lee

wrldwzrd89
Jul 26, 2008, 12:37 PM
My approach when I was using NetBeans was to add the jar from the dependencies dist directory to the depending project. Then, when you do a build of the depending project, it should copy that jar to the dist directory.

As long as /lib is in manifest.mf in the CLASS-PATH line, it should pick up your jar if you put it there.

-Lee
I agree, that should work... but NetBeans isn't copying the JAR file from wherever it is on the disk to the dist folder of the dependent project in the first place. If I add the JAR file to the dependency list of BOTH projects manually, it'll work properly, but this configuration is far from ideal for release purposes - i.e. the development build will work but the release build will fail.

wrldwzrd89
Jul 28, 2008, 07:29 AM
I've been experimenting with this but cannot, for the life of me, get it to work as I want it to... anyone else have ideas?

jeremy.king
Jul 29, 2008, 11:11 AM
I've been experimenting with this but cannot, for the life of me, get it to work as I want it to... anyone else have ideas?

I'd suggest creating a Class Library, adding your jars, then adding that new Class Library to both projects.