I want to use runtime to execute cmdline. This command is to generate example_jtl.jtl
and example_visual
(a blank folder and new file in here) by example.jmx
. The Java code is without error after running, but there is no new file and folder. What should I do?
try {
System.out.println("begin cmd");
Runtime mt = Runtime.getRuntime();
//mt.exec("cmd \\c ionic -v");
String cmd = "cmd D:\\Programming\\JMeter\\apache-jmeter-5.5\\bin\\jmeter -n -t D:\\Programming\\JMeter\\apache-jmeter-5.5\\result\\example.jmx -l D:\\Programming\\JMeter\\apache-jmeter-5.5\\result\\example_jtl.jtl -e -o D:\\Programming\\JMeter\\apache-jmeter-5.5\\result\\example_visual";
Process pro = mt.exec(cmd);
InputStream ers= pro.getErrorStream();
pro.waitFor();
} catch (IOException ioe) {
ioe.printStackTrace();
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
After the program is executed, the example_jtl.jtl
file and the example_visual
folder should be generated under the /result
folder.
I think you need to change your command from cmd
to cmd /c
because currently you're just kicking off a CMD instance and the rest is simply ignored.
Also be aware that it's possible to kick off a JMeter test using JMeter API, take a look at StandardJMeterEngine class JavaDoc and JMeter Command Line Overview: 5 Ways To Launch a Test article for more details if needed