I’m just trying to get my Java lib folders organized (using NetBeans).
What I want to have is something like this:
unknownNetworkDriveOrUncPath:\java\commonlib\
|-- fileio.jar
|-- ...
unknownNetworkDriveOrUncPath:\java\program1\
|-- lib\
|-- program1.jar
unknownNetworkDriveOrUncPath:\java\program2\
|-- lib\
|-- program2.jar
The lib folders inside the program folders contain specific jars. The commonlib folder contains jars every program may use.
So program1 should have access to its own lib folder and the common lib folder. The same goes for program2.
Best way would be to have the same structure within the dist folder after compiling. Then it would be possible just to copy the files to the desired location. But I don’t know how to do that.
Is there a “best practice” solution on how to configure NetBeans? I can’t use absolute or UNC paths since the network drive may differ.
Thanks in advance.
Regards.
What you’ll probably want is to modify the build.xml file which is present in your project directories. Netbeans uses Apache Ant as the tool which executes the build process. Ant is an XML based script. It’s split into multiple files in Netbeans but the only one you should modify is build.xml.
Read the comments in this file. They suggest that you should override certain targets to adjust the build process to suit your needs. For example we use the “-post-jar” target to create the entire install directory of our products inside the “dist” directory. As for non-absolute paths, I don’t think you’ll be able to achieve that but you can copy stuff to locations relative to your project directories. I would be entirely possible to have a common dist directory for multiple Netbeans projects.
The following would probably (haven’t tested it) copy your project’s JAR to “commonBuildDir” directory which should be located at the same level as your project directories.
${build.dir}references an Ant property, in this case a predefined one which points to the build directory of the project. Same goes for${dist.jar}which references the location of your project’s JAR file. Behind the sceenes these are all absolute paths if I remember correctly.Customizing Netbeans Build Script
Ant Tutorial
I think this should get you started to customize your build process the way you wish.