title: How to run a mvn command from a java program?
body: <p>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".</p>
  
  <p>I am building a java program and I am trying to run that command line but so far I wasn't successful. </p>
  
  <p>So far, here is the code:</p>
  
  <pre><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();
  }
  </code></pre>