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 7844347
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T16:50:55+00:00 2026-06-02T16:50:55+00:00

Need to run maven jaxb2 plugin from my app, at run-time. Is it possible?

  • 0

Need to run maven jaxb2 plugin from my app, at run-time. Is it possible?

  • 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-02T16:50:55+00:00Added an answer on June 2, 2026 at 4:50 pm

    Maybe i have done something that could help you:

    /**
     * @author swoeste
     * 
     */
    public class MavenExecutor {
    
    private final File       configuration;
    private final ClassWorld classWorld;
    
    /**
     * Constructor for a new maven executor.
     * 
     * @param aConfiguration
     */
    public MavenExecutor( final File aConfiguration ) {
        this.configuration = aConfiguration;
        this.classWorld = new ClassWorld( "plexus.core", this.getClass().getClassLoader() ); //$NON-NLS-1$
    }
    
    /**
     * This method is used to perform a mvn  command on the given pom. The original
     * command must be given, also the sub folder and the marker folder in the working directory. The working directory
     * and the configuration file will be added before execution.
     * 
     * @param cmd the mvn command to execute
     * @param pom the absolute path to a maven pom file
     * @param output the absolute path to the working directory
     * @param folder the output sub folder of the working directory
     * @param marker the marker sub folder of the working directory
     * @return
     */
    public int unpack( final String cmd, final File pom, final File output, final String folder, final String marker ) {
        final List<String> commands = new ArrayList<String>( //
                Arrays.asList( cmd.split( ConfigurationConstants.MAVEN_DELIMITER ) ) );
        commands.add( "-DoutputDirectory=" + output.getAbsolutePath() + folder ); //$NON-NLS-1$
        commands.add( "-DmarkersDirectory=" + output.getAbsolutePath() + marker ); //$NON-NLS-1$
        commands.add( "-gs=\"" + this.configuration.getAbsolutePath() + "\"" ); //$NON-NLS-1$//$NON-NLS-2$
        commands.add( "-f=\"" + pom.getAbsolutePath() + "\"" ); //$NON-NLS-1$ //$NON-NLS-2$
        return MavenCli.doMain( commands.toArray( new String[commands.size()] ), this.classWorld );
    }
    

    }

    I dont know what exactly you want to do, but if you want to execute a maven plugin on a maven project the above code will work. In my case i execute a mvn dependency:unpack-dependencies command on a project.

    To get the above working you need this dependency:

      <dependency>
         <groupId>org.apache.maven</groupId>
         <artifactId>maven-embedder</artifactId>
         <version>3.0.3</version>
      </dependency>
    

    PS: A good resource for information about how to execute maven things from java is the implementation of the m2eclipse plugin 😉

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

Sidebar

Related Questions

How to set VM arguments for Jetty run from maven-jetty-plugin? For example, I need
I have maven-plagin and need to run goal, that should automatically run before plugin.
From what I am reading, to run Maven on a Windows computer I need
I need to run Maven from the command line while Eclipse is open. Since
I can do this run ANT build.xml from Maven using ant run plugin .
I need run ts:reindex when smth add in model or destroy from model. How
I need to run an external application from within my Java code. I can
I need to run a windows command line tool from a php script on
i am trying to run integration test in separate maven profile, so i need
I need run all tests from my multimodule project using IDE. Like I do

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.