DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Please enter at least three characters to search
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Last call! Secure your stack and shape the future! Help dev teams across the globe navigate their software supply chain security challenges.

Modernize your data layer. Learn how to design cloud-native database architectures to meet the evolving demands of AI and GenAI workloads.

Releasing software shouldn't be stressful or risky. Learn how to leverage progressive delivery techniques to ensure safer deployments.

Avoid machine learning mistakes and boost model performance! Discover key ML patterns, anti-patterns, data strategies, and more.

Related

  • Private Remote Maven Repository With Artipie
  • How to Publish Artifacts to Maven Central
  • DGS GraphQL and Spring Boot
  • How to Build a New API Quickly Using Spring Boot and Maven

Trending

  • From Zero to Production: Best Practices for Scaling LLMs in the Enterprise
  • Beyond ChatGPT, AI Reasoning 2.0: Engineering AI Models With Human-Like Reasoning
  • How to Practice TDD With Kotlin
  • How to Configure and Customize the Go SDK for Azure Cosmos DB
  1. DZone
  2. Coding
  3. Java
  4. Creating Maven Artifacts From a jar File

Creating Maven Artifacts From a jar File

Here is a step-by-step guide for generating Maven artifacts from any third-party jar.

By 
Shirish Bari user avatar
Shirish Bari
·
Sep. 28, 16 · Tutorial
Likes (7)
Comment
Save
Tweet
Share
27.0K Views

Join the DZone community and get the full member experience.

Join For Free

Today, we're going to create an artifact from mailapi.jar with version 1.4.5 and use it in our Maven project. This article will guide you through the steps to make that happen.

Background

While creating Maven projects, we often come across a scenario when we have to import a jar from local repositories instead of Maven.

The reasons could be: 

  • The jar was created locally, and it’s not present in the Maven repository.
  • We want to use a specific version of the jar, maybe because of:
    • An upgrade that can be inconsistent with other dependencies.
    • An upgrade that could break functionality if it’s written with assumptions made for the current version.

We need to find an answer to the following questions:

  1. How can we create a Maven artifact from a jar?

  2. How can we configure this artifact in pom.xml?

Steps

  1. Create a Maven artifact from a jar

 Maven's Install Plugin can help us generate an artifact. Run:

mvn install:install-file -Dfile=<path to jar>\mailapi.jar 
-DgroupId=com.study  
-DartifactId=mailapi 
-Dversion=1.4.5  
-Dpackaging=jar  
-DcreateChecksum=true

            

Maven Install command

At the C:\Users\<userName>\.m2\repository\com\study\mailapi\ directory, you can see generated artifacts:

Artifacts

A parameter createChecksum=true creates integrity checksums (MD5, SHA-1) for the artifacts during installation.

2. Create a repo folder in <project base directory>.

3. First, copy the com folder from C:\Users\<userName>\.m2\repository\ to <project base directory>/repo.

4. Configure pom.xml to look up the local repository for specific jars.

pom.xml

Remember to use System Scope for jars referred from local repositories.

I hope this article will be helpful.

Artifact (UML) JAR (file format) Apache Maven

Opinions expressed by DZone contributors are their own.

Related

  • Private Remote Maven Repository With Artipie
  • How to Publish Artifacts to Maven Central
  • DGS GraphQL and Spring Boot
  • How to Build a New API Quickly Using Spring Boot and Maven

Partner Resources

×

Comments
Oops! Something Went Wrong

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends:

Likes
There are no likes...yet! 👀
Be the first to like this post!
It looks like you're not logged in.
Sign in to see who liked this post!