0

I tried the following in the Bean Shell Sampler;

Runtime rt = Runtime.getRuntime();
rt.exec("cmd.exe /c && cd /Program Files/Java/jdk1.8.0_51/jre/bin & java -jar File-2.0-SNAPSHOT.WAR");

It looks like, it is not able to run.. Am i doing in the correct way?

user123
  • 35
  • 2
  • 10
  • there are many things wrong with this... to begin with you are trying to run WAR as JAR, which is weird; the path `/Program Files/Java/jdk1.8.0_51/jre/bin` cannot possibly work on windows and the whole format of cmd is not right. Did you check help for `cmd /c` ? – timbre timbre May 25 '16 at 14:37
  • I got it working by using an OS Process Sampler. By adding Java as the command and -jar, {jar path} as the command parameters.@KirilS. Thanks for your response. – user123 May 25 '16 at 15:05
  • would you Please edit your question and provide the answer it worked . – Suman g May 25 '16 at 15:24

1 Answers1

1

If you need to do it with Beanshell, I would suggest the following amendment to the process command line:

cmd /c start java -jar .....

See cmd.exe documentation for more information

However in majority of cases it might be easier to use OS Process Sampler which allows executing arbitrary commands and programs. Check out How to Run External Commands and Programs Locally and Remotely from JMeter

Dmitri T
  • 159,985
  • 5
  • 83
  • 133