I'm just getting back into Java and I've been trying to figure out how exactly I should be organizing my project. I come from a C# background where you just have to make sure that the libraries you compile are retrievable by the executable (or other libraries) by keeping them in the same folders or subfolders, but java seems to do things differently.
In my Eclipse workspace I have my main project I'm working on (just one for now, more later) and it references external JARs (in my case, the gazillion of files of Apache Axis2).
Where should I be storing these libraries that my projects depends on when building? I will need to add everything to source control really soon, and so I can't keep referencing these JARs by absolute path on my machine. I read suggestions for putting this IN a subfolder of my main project, but I feel that's not ideal. I think I should be keeping them in the same source-controlled parent folder as the project, and somehow reference them through relative path (eclipse one does absolute path through the UI, really?), so something like:
c:\JavaProjects\MyProject c:\JavaProjects\axis2-1.5.4 c:\JavaProjects\%whatever other library%
Is there an even better way?
Ideally, you shouldn't be storing the libraries in your project. They can be retrieved by public (or private) repositories via so called dependency-management tools. The two most prominent ones are Maven and Ivy.
Eclipse (and any other IDE) has integration with these tools (via plugins) and adds the desired libraries to the classpath automatically. You only have to define them (together with their version) in a configuration file.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With