SlideShare a Scribd company logo
Simple ways to work with a  .jar file in
your local maven dependency setup
Alan Richardson
www.javafortesters.com
www.eviltester.com
www.compendiumdev.co.uk
www.seleniumsimplified.com
@eviltester
@EvilTester 1
Sometimes you want to work with a  jar file that isn't hosted in
maven central.
You can:
add  .jar files as an IntelliJ project dependency
install it locally to your  .m2 repository
add it to your project as a system scoped file
use a repository management tool: like Nexus or Archiva
publish the dependency to maven central
@EvilTester 2
Quick Hack ‐ add jar as an IntelliJ project
dependency
For very quick hacks, add the  .jar as an IntelliJ project
dependency and bypass maven.
Open Module Settings Add .jar as Library
I demonstrate this in my free Java Desktop Application Technical
Testing and you can read a blog post containing this information.
@EvilTester 3
Quick Hack ‐ add jar as an IntelliJ project
dependency
Very tactical approach:
it doesn't scale
it doesn't help you work with other people
it isn't very good for CI or version control
But it might help you get your immediate work done:
experiment
try something out
get a task completed
And then adopt one of the following approaches if it works.
@EvilTester 4
Add to project as system scoped file
As a short term tactic, I have also added the  .jar as a system
scoped file.
<dependency>
  <groupId>selenium_2_53_1</groupId>
  <artifactId>com.seleniumhq.selenium_2_53_1 </artifactId>
  <version>2.53.1</version>
  <scope>system</scope>
  <systemPath>
    C:/temp/selenium‐server‐standalone‐2.53.1.jar
  </systemPath>
</dependency>
I don't think it really scales strategically.
e.g. see blog post on seleniumsimplified.com/2016/06
@EvilTester 5
Install .jar locally to your  .m2 repository
To have the  .jar available as a dependency that I can bring in
using a normal maven include, I can install the  .jar locally to my
 .m2 directory and repository.
This is explained on the maven website:
https://maven.apache.org/guides/mini/guide‐3rd‐party‐jars‐
local.html
@EvilTester 6
Install .jar locally to your  .m2 repository
I use this approach when working with my RestMud game engine
I have split my game into two projects:
game engine
e.g. https://github.com/eviltester/restmud‐game‐engine
RestMud game, Web Server and REST API
I build a snapshot  .jar of the game engine locally for my work.
@EvilTester 7
Install .jar locally to your  .m2 repository
Install it into my  .m2 folder
mvn install:install‐file 
‐Dfile=target/restmud‐engine‐1.4‐SNAPSHOT.jar 
‐DpomFile=pom.xml
@EvilTester 8
Install .jar locally to your  .m2 repository
If I didn't have the  pom.xml file, I could still do this.
I just add the details from the  pom.xml into my command line:
mvn install:install‐file 
‐Dfile=target/restmud‐engine‐1.4‐SNAPSHOT.jar 
‐DgroupId=uk.co.compendiumdev 
‐DartifactId=restmud‐engine 
‐Dversion=1.4‐SNAPSHOT 
‐Dpackaging=jar
@EvilTester 9
Install .jar locally to your  .m2 repository
If I want the source code jar to be associated with the  .jar 
add the following argument to the command line:
‐Dsources=target/restmud‐engine‐1.4‐SNAPSHOT‐sources.jar
@EvilTester 10
Install .jar locally to your  .m2 repository
This allows me to keep the  pom.xml of my projects which
use the  .jar to remain as though the  .jar was on a
repository manager or in maven central.
good tactical approach,
supports a switch to longer term strategic development
@EvilTester 11
Use a repository management tool
You could install a dependency management tool
Nexus
Archiva
Your  .jar files are installed into this repository
which is accessible by your team,
and CI process
and not just your local development machine.
Maven docs on Repositories:
https://maven.apache.org/repository‐management.html
@EvilTester 12
Use a repository management tool
You have to:
install the dependency management tool
configure the  pom.xml to have a  <repositories> section and
point to your dependency management tool
This is a much more strategic approach and is
good for team work and continuous integration
processes.
@EvilTester 13
Publish to Maven Central
probably the most strategic long term approach,
requires you to make your work public.
All of the other approaches mentioned allow you to keep your work
to yourself.
It is quite a long process, so I won't describe it here, but I have a full
write up on my blog.
http://blog.javafortesters.com/2016/10/how‐to‐create‐and‐release‐
jar‐to‐maven.html
@EvilTester 14
Summary
Ultimate short term hack ‐ add as a dependency in your IDE
For quick hacks ‐ add it as  system scoped maven dependency
For personal work, or moving towards a strategic approach,
install locally to  .m2 
For longer term tactical work as a team, use a repository
manager
For strategic open source work, release to maven central
@EvilTester 15
Useful Links
Install  .jar into your local  .m2 folder or as System scope
https://maven.apache.org/guides/mini/guide‐3rd‐party‐jars‐
local.html
https://stackoverflow.com/questions/4955635/how‐to‐add‐
local‐jar‐files‐to‐a‐maven‐project
http://seleniumsimplified.com/2016/06/use_selenium_webdrive
r_jar_locally/
http://roufid.com/3‐ways‐to‐add‐local‐jar‐to‐maven‐project
Example code that has the mvn install instructions in it is my
restmud‐game‐engine
@EvilTester 16
End
Alan Richardson www.compendiumdev.co.uk
Linkedin ‐ @eviltester
Twitter ‐ @eviltester
Instagram ‐ @eviltester
Facebook ‐ @eviltester
Youtube ‐ EvilTesterVideos
Pinterest ‐ @eviltester
Github ‐ @eviltester
Slideshare ‐ @eviltester
@EvilTester 17
BIO
Alan is a test consultant who enjoys testing at a technical level
using techniques from psychotherapy and computer science. In his
spare time Alan is currently programming a multi‐user text
adventure game and some buggy JavaScript games in the style of
the Cascade Cassette 50. Alan is the author of the books "Dear Evil
Tester", "Java For Testers" and "Automating and Testing a REST API".
Alan's main website is compendiumdev.co.uk and he blogs at
blog.eviltester.com
@EvilTester 18

More Related Content

ODP
DIY Java & Kubernetes
PDF
Spring Boot
DOCX
Spring boot competitive tests
PDF
Spring IO '15 - Developing microservices, Spring Boot or Grails?
PDF
No Hugging, No Learning
PDF
Frontend SPOF
DOCX
Spring competitive tests
PPTX
Spring boot
DIY Java & Kubernetes
Spring Boot
Spring boot competitive tests
Spring IO '15 - Developing microservices, Spring Boot or Grails?
No Hugging, No Learning
Frontend SPOF
Spring competitive tests
Spring boot

What's hot (20)

PDF
Continuous Integration Testing in Django
PDF
Introduction to development with Django web framework
PDF
Get Hip with JHipster: Spring Boot + AngularJS + Bootstrap - DOSUG February 2016
PPTX
Grails Spring Boot
PDF
Front End Development for Back End Java Developers - Jfokus 2020
PPTX
2. auto deploy to tomcat on jenkins
PPT
Q4E and Eclipse IAM, Maven integration for Eclipse
PDF
Developing PWAs and Mobile Apps with Ionic, Angular, and JHipster - Devoxx Mo...
PDF
Who *is* Jenkins?
PDF
Welcome to Jenkins
PDF
Advanced Jasmine
KEY
Eclipse IAM, Maven Integration For Eclipse
PDF
20150415 Something About Meteor
PDF
Cookbook Reusability @ Chef Community summit 2014
PDF
10 less-known Laravel Packages: May 2016
PDF
Running jenkins in a public cloud - common issues and some solutions
PPTX
SQL Server - CLR integration
PDF
Automatic Functional Testing with Selenium and SauceLabs
PDF
What's New in JHipsterLand - DevNexus 2017
PDF
Jenkins Best Practices
Continuous Integration Testing in Django
Introduction to development with Django web framework
Get Hip with JHipster: Spring Boot + AngularJS + Bootstrap - DOSUG February 2016
Grails Spring Boot
Front End Development for Back End Java Developers - Jfokus 2020
2. auto deploy to tomcat on jenkins
Q4E and Eclipse IAM, Maven integration for Eclipse
Developing PWAs and Mobile Apps with Ionic, Angular, and JHipster - Devoxx Mo...
Who *is* Jenkins?
Welcome to Jenkins
Advanced Jasmine
Eclipse IAM, Maven Integration For Eclipse
20150415 Something About Meteor
Cookbook Reusability @ Chef Community summit 2014
10 less-known Laravel Packages: May 2016
Running jenkins in a public cloud - common issues and some solutions
SQL Server - CLR integration
Automatic Functional Testing with Selenium and SauceLabs
What's New in JHipsterLand - DevNexus 2017
Jenkins Best Practices
Ad

Similar to Simple ways to add and work with a `.jar` file in your local maven setup (20)

PDF
Exploring Maven SVN GIT
PPT
Maven 2.0 - Project management and comprehension tool
PDF
A-Z_Maven.pdf
PPTX
PPT
Using Maven2
PDF
Java, Eclipse, Maven & JSF tutorial
PPT
Maven with Flex
PPT
Maven with Flex
ODP
PPT
Maven 2 features
PPT
Groovy Maven Builds
PDF
Liferay maven sdk
PPT
Maven: Managing Software Projects for Repeatable Results
PPT
Maven 2.0 - Improve your build patterns
PDF
Introduction maven3 and gwt2.5 rc2 - Lesson 01
ODP
7 Habits of Highly Effective Jenkins Users
PDF
php-and-zend-framework-getting-started
PDF
php-and-zend-framework-getting-started
PDF
php-and-zend-framework-getting-started
PDF
Exploring Maven SVN GIT
Maven 2.0 - Project management and comprehension tool
A-Z_Maven.pdf
Using Maven2
Java, Eclipse, Maven & JSF tutorial
Maven with Flex
Maven with Flex
Maven 2 features
Groovy Maven Builds
Liferay maven sdk
Maven: Managing Software Projects for Repeatable Results
Maven 2.0 - Improve your build patterns
Introduction maven3 and gwt2.5 rc2 - Lesson 01
7 Habits of Highly Effective Jenkins Users
php-and-zend-framework-getting-started
php-and-zend-framework-getting-started
php-and-zend-framework-getting-started
Ad

More from Alan Richardson (20)

PDF
Add More Security To Your Testing and Automating - Saucecon 2021
PDF
Automating to Augment Testing
PDF
Open source tools - Test Management Summit - 2009
PDF
Automating Tactically vs Strategically SauceCon 2020
PDF
The Future of Testing Webinar
PDF
Devfest 2019-slides
PDF
Secrets and Mysteries of Automated Execution Keynote slides
PDF
Automating Pragmatically - Testival 20190604
PDF
Joy of Coding Conference 2019 slides - Alan Richardson
PDF
Programming katas for Software Testers - CounterStrings
PDF
Technology Based Testing
PDF
About Consultant Alan Richardson Compendium Developments Evil Tester
PDF
Shift left-testing
PDF
Automating and Testing a REST API
PDF
Technical and Testing Challenges: Using the "Protect The Square" Game
PDF
TDD - Test Driven Development - Java JUnit FizzBuzz
PDF
If you want to automate, you learn to code
PDF
How To Test With Agility
PDF
Your Automated Execution Does Not Have to be Flaky
PDF
What is Testability vs Automatability? How to improve your Software Testing.
Add More Security To Your Testing and Automating - Saucecon 2021
Automating to Augment Testing
Open source tools - Test Management Summit - 2009
Automating Tactically vs Strategically SauceCon 2020
The Future of Testing Webinar
Devfest 2019-slides
Secrets and Mysteries of Automated Execution Keynote slides
Automating Pragmatically - Testival 20190604
Joy of Coding Conference 2019 slides - Alan Richardson
Programming katas for Software Testers - CounterStrings
Technology Based Testing
About Consultant Alan Richardson Compendium Developments Evil Tester
Shift left-testing
Automating and Testing a REST API
Technical and Testing Challenges: Using the "Protect The Square" Game
TDD - Test Driven Development - Java JUnit FizzBuzz
If you want to automate, you learn to code
How To Test With Agility
Your Automated Execution Does Not Have to be Flaky
What is Testability vs Automatability? How to improve your Software Testing.

Recently uploaded (20)

PDF
How to Choose the Right IT Partner for Your Business in Malaysia
PPTX
Operating system designcfffgfgggggggvggggggggg
PDF
Digital Strategies for Manufacturing Companies
PDF
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
PDF
How Creative Agencies Leverage Project Management Software.pdf
PDF
System and Network Administraation Chapter 3
PDF
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
PPTX
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
PDF
Nekopoi APK 2025 free lastest update
PPTX
Odoo POS Development Services by CandidRoot Solutions
PPTX
L1 - Introduction to python Backend.pptx
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
PDF
Navsoft: AI-Powered Business Solutions & Custom Software Development
PDF
PTS Company Brochure 2025 (1).pdf.......
PPTX
Introduction to Artificial Intelligence
PDF
Design an Analysis of Algorithms I-SECS-1021-03
PPTX
ManageIQ - Sprint 268 Review - Slide Deck
PDF
top salesforce developer skills in 2025.pdf
PPTX
CHAPTER 12 - CYBER SECURITY AND FUTURE SKILLS (1) (1).pptx
PDF
System and Network Administration Chapter 2
How to Choose the Right IT Partner for Your Business in Malaysia
Operating system designcfffgfgggggggvggggggggg
Digital Strategies for Manufacturing Companies
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
How Creative Agencies Leverage Project Management Software.pdf
System and Network Administraation Chapter 3
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
Nekopoi APK 2025 free lastest update
Odoo POS Development Services by CandidRoot Solutions
L1 - Introduction to python Backend.pptx
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
Navsoft: AI-Powered Business Solutions & Custom Software Development
PTS Company Brochure 2025 (1).pdf.......
Introduction to Artificial Intelligence
Design an Analysis of Algorithms I-SECS-1021-03
ManageIQ - Sprint 268 Review - Slide Deck
top salesforce developer skills in 2025.pdf
CHAPTER 12 - CYBER SECURITY AND FUTURE SKILLS (1) (1).pptx
System and Network Administration Chapter 2

Simple ways to add and work with a `.jar` file in your local maven setup

  • 1. Simple ways to work with a  .jar file in your local maven dependency setup Alan Richardson www.javafortesters.com www.eviltester.com www.compendiumdev.co.uk www.seleniumsimplified.com @eviltester @EvilTester 1
  • 2. Sometimes you want to work with a  jar file that isn't hosted in maven central. You can: add  .jar files as an IntelliJ project dependency install it locally to your  .m2 repository add it to your project as a system scoped file use a repository management tool: like Nexus or Archiva publish the dependency to maven central @EvilTester 2
  • 3. Quick Hack ‐ add jar as an IntelliJ project dependency For very quick hacks, add the  .jar as an IntelliJ project dependency and bypass maven. Open Module Settings Add .jar as Library I demonstrate this in my free Java Desktop Application Technical Testing and you can read a blog post containing this information. @EvilTester 3
  • 4. Quick Hack ‐ add jar as an IntelliJ project dependency Very tactical approach: it doesn't scale it doesn't help you work with other people it isn't very good for CI or version control But it might help you get your immediate work done: experiment try something out get a task completed And then adopt one of the following approaches if it works. @EvilTester 4
  • 5. Add to project as system scoped file As a short term tactic, I have also added the  .jar as a system scoped file. <dependency>   <groupId>selenium_2_53_1</groupId>   <artifactId>com.seleniumhq.selenium_2_53_1 </artifactId>   <version>2.53.1</version>   <scope>system</scope>   <systemPath>     C:/temp/selenium‐server‐standalone‐2.53.1.jar   </systemPath> </dependency> I don't think it really scales strategically. e.g. see blog post on seleniumsimplified.com/2016/06 @EvilTester 5
  • 6. Install .jar locally to your  .m2 repository To have the  .jar available as a dependency that I can bring in using a normal maven include, I can install the  .jar locally to my  .m2 directory and repository. This is explained on the maven website: https://maven.apache.org/guides/mini/guide‐3rd‐party‐jars‐ local.html @EvilTester 6
  • 7. Install .jar locally to your  .m2 repository I use this approach when working with my RestMud game engine I have split my game into two projects: game engine e.g. https://github.com/eviltester/restmud‐game‐engine RestMud game, Web Server and REST API I build a snapshot  .jar of the game engine locally for my work. @EvilTester 7
  • 8. Install .jar locally to your  .m2 repository Install it into my  .m2 folder mvn install:install‐file  ‐Dfile=target/restmud‐engine‐1.4‐SNAPSHOT.jar  ‐DpomFile=pom.xml @EvilTester 8
  • 9. Install .jar locally to your  .m2 repository If I didn't have the  pom.xml file, I could still do this. I just add the details from the  pom.xml into my command line: mvn install:install‐file  ‐Dfile=target/restmud‐engine‐1.4‐SNAPSHOT.jar  ‐DgroupId=uk.co.compendiumdev  ‐DartifactId=restmud‐engine  ‐Dversion=1.4‐SNAPSHOT  ‐Dpackaging=jar @EvilTester 9
  • 10. Install .jar locally to your  .m2 repository If I want the source code jar to be associated with the  .jar  add the following argument to the command line: ‐Dsources=target/restmud‐engine‐1.4‐SNAPSHOT‐sources.jar @EvilTester 10
  • 11. Install .jar locally to your  .m2 repository This allows me to keep the  pom.xml of my projects which use the  .jar to remain as though the  .jar was on a repository manager or in maven central. good tactical approach, supports a switch to longer term strategic development @EvilTester 11
  • 12. Use a repository management tool You could install a dependency management tool Nexus Archiva Your  .jar files are installed into this repository which is accessible by your team, and CI process and not just your local development machine. Maven docs on Repositories: https://maven.apache.org/repository‐management.html @EvilTester 12
  • 13. Use a repository management tool You have to: install the dependency management tool configure the  pom.xml to have a  <repositories> section and point to your dependency management tool This is a much more strategic approach and is good for team work and continuous integration processes. @EvilTester 13
  • 14. Publish to Maven Central probably the most strategic long term approach, requires you to make your work public. All of the other approaches mentioned allow you to keep your work to yourself. It is quite a long process, so I won't describe it here, but I have a full write up on my blog. http://blog.javafortesters.com/2016/10/how‐to‐create‐and‐release‐ jar‐to‐maven.html @EvilTester 14
  • 15. Summary Ultimate short term hack ‐ add as a dependency in your IDE For quick hacks ‐ add it as  system scoped maven dependency For personal work, or moving towards a strategic approach, install locally to  .m2  For longer term tactical work as a team, use a repository manager For strategic open source work, release to maven central @EvilTester 15
  • 16. Useful Links Install  .jar into your local  .m2 folder or as System scope https://maven.apache.org/guides/mini/guide‐3rd‐party‐jars‐ local.html https://stackoverflow.com/questions/4955635/how‐to‐add‐ local‐jar‐files‐to‐a‐maven‐project http://seleniumsimplified.com/2016/06/use_selenium_webdrive r_jar_locally/ http://roufid.com/3‐ways‐to‐add‐local‐jar‐to‐maven‐project Example code that has the mvn install instructions in it is my restmud‐game‐engine @EvilTester 16
  • 17. End Alan Richardson www.compendiumdev.co.uk Linkedin ‐ @eviltester Twitter ‐ @eviltester Instagram ‐ @eviltester Facebook ‐ @eviltester Youtube ‐ EvilTesterVideos Pinterest ‐ @eviltester Github ‐ @eviltester Slideshare ‐ @eviltester @EvilTester 17
  • 18. BIO Alan is a test consultant who enjoys testing at a technical level using techniques from psychotherapy and computer science. In his spare time Alan is currently programming a multi‐user text adventure game and some buggy JavaScript games in the style of the Cascade Cassette 50. Alan is the author of the books "Dear Evil Tester", "Java For Testers" and "Automating and Testing a REST API". Alan's main website is compendiumdev.co.uk and he blogs at blog.eviltester.com @EvilTester 18