I'm trying to execute performance with Jmeter from Java.

My code is written below.

I'm facing an issue generating dashboard report.

I want to dashboard report to be written in "Target" folder within the project folder in Ecipse workspace.

With the first test run the dashboard report is generated properly.

The problem occurs when I run a second test. The problem/cause as I see is a statistics.json file that is generated in the project folder > report-output folder in the Eclipse workspace. If I delete this statistics.json file and run the test again, it works fine and also generated he dashboard report.

Is it possible to change the location of this statistics.json file to the same "Target" folder?


Is it possible to have a dynamic name for it?


Delete the existing statistics.json json file before each run?


package JmeterJava;
import org.apache.jmeter.engine.StandardJMeterEngine;
import org.apache.jmeter.report.dashboard.ReportGenerator;
import org.apache.jmeter.reporters.ResultCollector;
import org.apache.jmeter.reporters.Summariser;
import org.apache.jmeter.save.SaveService;
import org.apache.jmeter.util.JMeterUtils;
import org.apache.jorphan.collections.HashTree;

import java.io.File;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;

public class Jmeter {

    public static void main(String[] argv) throws Exception {
        // JMeter Engine
        StandardJMeterEngine jmeter = new StandardJMeterEngine();
        //Define date format...
        DateFormat df = new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss");
        String currentDate = df.format(new Date());

        // Initialize Properties, logging, locale, etc.
        JMeterUtils.setProperty("jmeter.reportgenerator.exporter.html.classname", "org.apache.jmeter.report.dashboard.HtmlTemplateExporter");
        JMeterUtils.setProperty("jmeter.reportgenerator.exporter.html.property.output_dir","Target/dashboard" + currentDate);
        //JMeterUtils.initLogging();// you can comment this line out to see extra log messages of i.e. DEBUG level

        // Initialize JMeter SaveService

        // Load existing .jmx Test Plan
        HashTree testPlanTree = SaveService.loadTree(new File("/home/user/test-plan.jmx"));

      //add Summarizer output to get test progress in stdout like:
        // summary =      2 in   1.3s =    1.5/s Avg:   631 Min:   290 Max:   973 Err:     0 (0.00%)
        Summariser summer = null;
        String summariserName = JMeterUtils.getPropDefault("summariser.name", "summary");
        if (summariserName.length() > 0) {
            summer = new Summariser(summariserName);

        // Store execution results into a .jtl file
        String logFile = "./Target/Result-" + currentDate + ".jtl";
        ResultCollector logger = new ResultCollector(summer);
        testPlanTree.add(testPlanTree.getArray()[0], logger);
        // Run JMeter Test
        // Generate HTML Report Dashboard
        ReportGenerator generator = new ReportGenerator(logFile, null);



Exception in thread "main" java.lang.IllegalArgumentException: Cannot write to '/home/user/eclipse-workspace/Jmeter/report-output' as folder is not empty

1 Answer 1


There is a special property which configures the dashboard output folder: jmeter.reportgenerator.exporter.json.property.output_dir defaulting to report-output

You're getting this error because you're running your dashboard generation 2nd time and the aforementioned folder is not empty.

The workaround would be removing this directory in the beginning of your function using i.e. FileUtils.deleteDirectory() method, something like:

org.apache.commons.io.FileUtils.deleteDirectory(new File("report-output"));

Also be aware that according to 9 Easy Solutions for a JMeter Load Test “Out of Memory” Failure article you should always be using the latest version of JMeter so consider upgrading to JMeter 5.4.1 or whatever is the latest stable version available at JMeter Downloads page.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.