Creating war file using Process and Runtime class........

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class CreateWar {

public static void main(String[]args) {

String temp="c:/createbat.bat";// have command in batch file commands are cd:/ , c:/ , jar -cvf c:/test.war -C c:/lookup
// these lines are very important. jar-cvf is used to create the war file.
BufferedReader br = executeProgram(temp);

String line = new String();
try {
while ((line = br.readLine()) != null) {
System.out.println(line);
}
} catch (IOException e) {

System.out.println("The Files are Failed");
e.printStackTrace();
}
}


private static BufferedReader executeProgram (String pgm)
{
System.out.println("pgm "+pgm);
// creating war file by using the runtime and process class....
Runtime r = Runtime.getRuntime();
Process p = null;
try
{
// String[] envarray={"JAVA_HOME",System.getProperty("JAVA_HOME")};
p = r.exec(pgm);

return (new BufferedReader(new InputStreamReader(p.getInputStream())));
} catch (Exception e) {
System.out.println("The Files are Failed");
e.printStackTrace();
return (null);
}
}
}

Comments

Popular posts from this blog

Spring MVC with Sqlite sample

Struts Tutorial Page