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

  • SEARCH
  • Home
  • 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 7697527
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T22:02:12+00:00 2026-05-31T22:02:12+00:00

I have a project, in which I want to invoke another Jar file in

  • 0

I have a project, in which I want to invoke another Jar file in M2 repo during the post execution phase of the current project.

Sample skeleton of my POM

<plugin>
          <groupId>org.codehaus.mojo</groupId>
          <artifactId>exec-maven-plugin</artifactId>
          <version>1.1</version>

            <executions>
              <execution>
              <id>exec-one</id>
              <phase>verify</phase>
              <configuration>
                  executable>java</executable>
                  <arguments> <argument>-jar</argument>
                  <argument>JarToInvoke.jar</argument>
                  </arguments>                
                  <**workingDirectory**>/C:/path to repo</workingDirectory>
                  </configuration>
                      <goals>
                         <goal>exec</goal>
                      </goals>
                  </execution>
                  </executions>

              <dependencies> <dependency>
                 <groupId>GroupId of JarToInvoke</groupId>
                 <artifactId>JarToInvoke</artifactId>
               <version>1.0.0-SNAPSHOT</version>
              </dependency>
              </dependencies>
            </plugin>    
          </plugins>

I tried with maven-exec-plugin, but having the following issues;

  1. Where I need to specify to JarToInvoke dependency ? As a project dependency or as a exec-plugin dependency ?

  2. With hard coding the working directory(/C:/path to repo), I am able to invoke the JarToInvoke artifact. But it is not a good solution, because finally this project should run in any m/c with different OS’s. So how can I make the exec-plugin to search for the JarToInvoke artifact in the M2 repo of the project(default classpath) ?

3.While hard coding the M2 repo path in the working directory, I was able to invoke the JarToInvoke artifact. But while running the JarToInvoke artifact, it throws another dependency issue, some of the log4j dependencies to the JarToInvoke could not find. I made the JarToInvoke as a shaded jar and it work as expected. But it is not a permanent or good solution(Because the shaded jar size is of 35 MB). How can I instruct the exec-plugin to look for the dependent Jars in M2 repo.

Please share your suggestions. Thanks in Advance.

  • 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-05-31T22:02:14+00:00Added an answer on May 31, 2026 at 10:02 pm

    This example page from the Exec plugin’s documentation describes what you want I think.

    If you could use the exec:java goal instead of exec:exec, finding the JVM is taken care of for you. You can also pull in either plugin dependencies or project dependencies by changing the includeProjectDependencies and includePluginDependencies configuration options of the plugin.

    <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>exec-maven-plugin</artifactId>
        <version>1.1</version>
    
        <executions>
            <execution>
                <id>exec-one</id>
                <phase>verify</phase>
                <configuration>
                    <includeProjectDependencies>false</includeProjectDependencies>
                    <includePluginDependencies>true</includePluginDependencies>
                    <executableDependency>
                        <groupId>GroupId of JarToInvoke</groupId>
                        <artifactId>JarToInvoke</artifactId>
                    </executableDependency>
    
                    <!-- Look up the main class from the manifest inside your dependency's JAR -->
                    <mainClass>com.example.Main</mainClass>
                    <arguments>
                        <!-- Add any arguments after your JAR here --->
                    </arguments>
                </configuration>
                <goals>
                  <goal>java</goal>
               </goals>
            </execution>
        </executions>
    
        <dependencies>
            <dependency>
                <groupId>GroupId of JarToInvoke</groupId>
                <artifactId>JarToInvoke</artifactId>
                <version>1.0.0-SNAPSHOT</version>
            </dependency>
        </dependencies>
    </plugin>    
    

    The only disadvantage is that you have to explicitly specify the main class in the JAR to run. You can look this up by opening up the manifest in the dependency JAR and read the Main-Class attribute.

    If you really need to use exec:exec, you could use the Maven Dependency Plugin’s copy-dependencies goal to copy dependencies from your local repository to a predefined location (such as ${project.build.directory}/exec-jars) and then you can feed this directory in the exec plugin’s workingDirectory configuration option.

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

Sidebar

Related Questions

I have a console project which I want to start with some parameters argc
I have a Blackberry project in which I want to change normal image to
I have a static class in a shared project, which I want to extend
I have a project which uses strongly typed datasets. Let's assume I want to
I have a project which is using DocumentFormat.OpenXml.dll 2.0.3920.0. However, I want this to
I have an project which is dependent on the another project. But now i
I have a CodeIgniter project, and I want to invoke one of my controller
I have project in which I want to use check library for unit testing.
I have an old project which i want to compile with the 4.1.2 version
I have a Rails 2.2 project in which I want to override the functionality

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.