Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8341001
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T05:20:26+00:00 2026-06-09T05:20:26+00:00

I am trying to write a java program that takes a maven pom.xml file

  • 0

I am trying to write a java program that takes a maven pom.xml file as input and does following:

  1. Downloads all dependencies
  2. Adds jars to classpath
  3. Executes java code (loaded from the jars)

Is it possible? any sample code to achieve #1 above will be greatly appreciated

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T05:20:28+00:00Added an answer on June 9, 2026 at 5:20 am

    If you absolutely have to do this embeded in a Java app:

    The library Maven uses under the covers to do dependency resolution is called Aether. If you take a look at the documentation on the Sonatype site there’s an example of how to do step 1. Part of the dependency resolution process will give you access to a list of dependencies which you can then loop over to build your classpath.

    For step 3 you could use a ProcessBuilder and launch the target Java app as a subprocess of the JVM that used Aether to build the classpath.

    If you can use a shell script:

    You can use mvn dependency:get -Dartifact=[group]:[artifact]:[version] to download the artifacts to your local repo.

    Then you can use mvn dependency:build-classpath to generate the classpath string.

    Then you can simply execute java with a -cp option. You’d have to also know what main class you want is, or you could compute the name of the primary jar from the artifact and version number and pass that to -jar.

    If you’re able to get the pom.xml of the main project in your deployment environment:

    You can just use mvn exec:java -DmainClass=com.company.package.YourMainClass. This option is by far the simplest, but it does have the downside of executing within the maven JVM and as far as I’ve been able to find out there’s no option for forking a separate process. Also you need to have a full fledged pom to make this work which isn’t always convenient.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to write a Java program that reads an input file consisting
I'm trying to write a really small program in Java that takes a string
I'm trying to write a payroll program that simply receives input, does some calculations
I am trying at write a java program that hits a url over ssl,
I'm trying to follow Java's JDBC tutorials to write a Java program that can
I'm trying to write a program in Java that uses osql to generate a
I'm trying to write a program in Java that looks for patterns of strings
I am trying to write a simple java program which returns me all the
I am trying to write a java program that will automatically download and name
I'm trying to write a program in Java that when given an MxN matrix

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.