My code here, I want to ececute jmeter shell command in IBM cloud through Java.
Runtime run = Runtime.getRuntime();
Process pr = run.exec("./JMeter/apache-jmeter-4.0/bin/jmeter -n
-t ./JMX/"+FileName+" -l ./JTL/Generate_Dashboard.jtl -e -o
./Result/"+Name+""");
pr.waitFor();
BufferedReader buf = new BufferedReader(new
InputStreamReader(pr.getInputStream()));
String line = "";
while ((line=buf.readLine())!=null) {
System.out.println(line);
}
jmeter.sh
script instead of jmeter
, it performs environment check, sets up variables, JVM options when it comes to Java 9, etc. You need to ensure that both jmeter.sh
and jmeter
have execute permissions, i.e. execute the following command:
chmod +x /JMeter/apache-jmeter-4.0/bin/jmeter && chmod +x /JMeter/apache-jmeter-4.0/bin/jmeter.sh
I don't think you need these dots in your command, to wit you need to amend your command to look like:
Process pr = run.exec("/JMeter/apache-jmeter-4.0/bin/jmeter -n -t /JMX/"+FileName+" -l /JTL/Generate_Dashboard.jtl -e -o /Result/"+Name+""");
More information: Five Ways To Launch a JMeter Test without Using the JMeter GUI