Hi I want to execute this command from java code :
cd C:/Users/Amira/junoWorkspace/TestProjectUI
mvn -Dtest=MyClassTest.java test
So I found this method but i didn't find a way to adapt it to my case :
public static void main(String[] args) throws IOException
{
try
{
// Runtime runtime = Runtime.getRuntime();
String[] cmd={"C:\\WINDOWS\\System32\\cmd.exe","/C start test.bat"};
Process p = Runtime.getRuntime().exec(cmd);
// TODO code application logic here
}
catch(IOException e)
{
System.err.println("echec de l'execution du script: "+e);
System.exit(1);
}
}
Any idea ? Cheers
What you are looking for is ProcessBuilder
which will allow you to set arguments like the working directory etc, it will also allow for multiple arguments, check here and here and ProcessBuilder Demo for some examples on how to use it