How to run a jar file from Jmeter?

喜你入骨 提交于 2019-12-25 07:35:12

问题


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?


回答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



来源:https://stackoverflow.com/questions/37438576/how-to-run-a-jar-file-from-jmeter

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!