0

when I execute this class in an IDE from main ,everything works fine:

Runtime p = Runtime.getRuntime();
String[] commands = new String[3];
commands[0] = "cmd";
commands[1] = "/c";
commands[2] = "\\something\\something\\curl.exe ... ;
Process x = p.exec(commands);

BufferedReader in = new BufferedReader(
new InputStreamReader(x.getInputStream()));
String line = null;
while ((line = in.readLine()) != null) {
System.out.println(line);
}

but if I build WAR and execute this method from web application - The line containing null (p.exec(commands) - does not work correctly), How do I improve this situation ?

Aswin Murugesh
  • 10,831
  • 10
  • 40
  • 69
user2519456
  • 21
  • 1
  • 5
  • \\something\\something\\curl.exe must be present "Relative" to the Main class you have run.. have u zipped the exe into the war file? – sanbhat Jun 25 '13 at 09:55
  • Why do you want to start curl, if java has all you need to do the same?! i.e. http://stackoverflow.com/questions/116650/curl-equivalent-in-java and http://stackoverflow.com/questions/2586975/how-to-use-curl-in-java – Sammy Jun 25 '13 at 09:55
  • ok, thanks Sammy - This is very "strange and poor" curl, the begin of this curl: 7|3|15|http://... SanBat - how may I pack exe to war ? Must I change something in pom ? If yes, how ? thanks Mike – user2519456 Jun 25 '13 at 10:04
  • ok, I have exe in this folder (in WAR) :WEB-INF\classes\curl.exe. How May I modify commands[2] = "\\something\\something\\curl.exe ... ; ? – user2519456 Jun 25 '13 at 10:10

0 Answers0