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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T21:27:31+00:00 2026-06-02T21:27:31+00:00

I am building a Java program for automating a procedure in my server side.

  • 0

I am building a Java program for automating a procedure in my server side. Normally I cd to Desktop/GIT/ and use this maven command “mvn integration-test -DskipTests -P interactive -e”.

I am building a java program and I am trying to run that command line but so far I wasn’t successful.

So far, here is the code:

public static void main(String[] args) throws FileNotFoundException {
// TODO Auto-generated method stub 

Process theProcess = null;


try
  {
      theProcess = Runtime.getRuntime().exec("mvn integration-test -DskipTests -P interactive -e");
  }
 catch(IOException e)
  {
     System.err.println("Error on exec() method");
     e.printStackTrace();  
  }

// read from the called program's standard output stream
  try
  {
     inStream = new BufferedReader(new InputStreamReader( theProcess.getInputStream()));  
     System.out.println(inStream.readLine());
  }
  catch(IOException e)
  {
     System.err.println("Error on inStream.readLine()");
     e.printStackTrace();  
  }

break;

    }

}

in.close();
}
  • 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-02T21:27:32+00:00Added an answer on June 2, 2026 at 9:27 pm

    I managed to run the mvn using the following code:
    (I use this command: Runtime.getRuntime().exec(cmd);)

        import java.io.*;
        import java.util.ArrayList;
    
    
        public class RunMvnFromJava     {
                static public String[] runCommand(String cmd)throws IOException
    {
    
                    // The actual procedure for process execution:
                    //runCommand(String cmd);
                    // Create a list for storing output.
                    ArrayList list = new ArrayList();
                    // Execute a command and get its process handle
                    Process proc = Runtime.getRuntime().exec(cmd);
                    // Get the handle for the processes InputStream
                    InputStream istr = proc.getInputStream();
                    // Create a BufferedReader and specify it reads
                    // from an input stream.
    
                    BufferedReader br = new BufferedReader(new InputStreamReader(istr));
                    String str; // Temporary String variable
                    // Read to Temp Variable, Check for null then
                    // add to (ArrayList)list
                    while ((str = br.readLine()) != null) 
                        list.add(str);
                        // Wait for process to terminate and catch any Exceptions.
                            try { 
                                proc.waitFor(); 
                                }
                            catch (InterruptedException e) {
                                System.err.println("Process was interrupted"); 
                                }
                            // Note: proc.exitValue() returns the exit value.
                            // (Use if required)
                            br.close(); // Done.
                            // Convert the list to a string and return
                            return (String[])list.toArray(new String[0]);
    }
    // Actual execution starts here
                public static void main(String args[]) throws IOException
                {
                    try
                    {
                        // Run and get the output.
                        String outlist[] = runCommand("mvn integration-test -DskipTests -P interactive -e");
                        // Print the output to screen character by character.
                        // Safe and not very inefficient.
                        for (int i = 0; i < outlist.length; i++)
                            System.out.println(outlist[i]);
                    }   
                    catch (IOException e) { 
                        System.err.println(e); 
                    }
                }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I use Maven for building Java projects. The output of Maven has immense size.
I'm coming from the Java world and are building a small c++ program at
I'm currently working on building a java web app. I've been looking to use
I'm currently working on a project that is building a java-based desktop application to
I'm building this small java applet in which I need a JPanel which will
I am following the video on this page http://zegoggl.es/2009/12/building-android-apps-in-scala-with-sbt.html which use SBT to create
I am building a small Java program for a Mac user who is an
What are the implications of building a java program against the jars of one
I created a Java program that will process files using a C++ program. This
I am building a project in Java. I have this error: Unable to locate

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.