简体   繁体   English

如何从Jmeter运行jar文件?

[英]How to run a jar file from Jmeter?

I tried the following in the Bean Shell Sampler; 我在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? 看来,它无法运行。.我是否以正确的方式进行操作?

If you need to do it with Beanshell, I would suggest the following amendment to the process command line: 如果您需要使用Beanshell进行此操作,建议对process命令行进行以下修改:

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

See cmd.exe documentation for more information 有关更多信息,请参见cmd.exe文档

However in majority of cases it might be easier to use OS Process Sampler which allows executing arbitrary commands and programs. 但是在大多数情况下,使用OS Process Sampler可能会更容易,它允许执行任意命令和程序。 Check out How to Run External Commands and Programs Locally and Remotely from JMeter 了解如何从JMeter本地和远程运行外部命令和程序

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM