Search code examples
jarnaming-conventions

Adding external libraries to project


In my case I'm developing a Java web app and I want to add the Jersey JAX-RS API, but this question is general:

Is there any recommended/professional/best way to add external APIs to our projects?

I mean, in my university projects I always just import the jar files into my project in Eclipse/NetBeans, but I was wondering if there's a more professional way, also regarding to licenses and so on...


Solution

  • More professional way is to use Dependency Management Tools like Gradle, Maven, Ivy etc for your project.

    Maven

    <dependency>
        <groupId>com.sun.jersey</groupId>
        <artifactId>jersey-server</artifactId>
        <version>1.17.1</version>
    </dependency>
    

    Gradle

    'com.sun.jersey:jersey-server:1.17.1'
    

    Ivy

    <dependency org="com.sun.jersey" name="jersey-server" rev="1.17.1"/>
    

    After this, there is single place in your project when all external libraries/apis are defined. There is very easy to check what you are using, much easier than looking inside JAR file for additional information.