NetBeans project JAR dependency chain management

Discussion in 'Mac Programming' started by wrldwzrd89, Jul 26, 2008.

  1. wrldwzrd89 macrumors G5

    wrldwzrd89

    Joined:
    Jun 6, 2003
    Location:
    Solon, OH
    #1
    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:
     
  2. lee1210 macrumors 68040

    lee1210

    Joined:
    Jan 10, 2005
    Location:
    Dallas, TX
    #2
    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
     
  3. wrldwzrd89 thread starter macrumors G5

    wrldwzrd89

    Joined:
    Jun 6, 2003
    Location:
    Solon, OH
    #3
    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.
     
  4. lee1210 macrumors 68040

    lee1210

    Joined:
    Jan 10, 2005
    Location:
    Dallas, TX
    #4
    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
     
  5. wrldwzrd89 thread starter macrumors G5

    wrldwzrd89

    Joined:
    Jun 6, 2003
    Location:
    Solon, OH
    #5
    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.
     
  6. wrldwzrd89 thread starter macrumors G5

    wrldwzrd89

    Joined:
    Jun 6, 2003
    Location:
    Solon, OH
    #6
    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?
     
  7. jeremy.king macrumors 603

    jeremy.king

    Joined:
    Jul 23, 2002
    Location:
    Fuquay Varina, NC
    #7
    I'd suggest creating a Class Library, adding your jars, then adding that new Class Library to both projects.
     

Share This Page