7
votes

When i run my JMeter script on commandline mode, i am getting below error.

But the same script is running perfectly fine on GUI mode.

Need some help here to fix this.

Below is the error:

C:\Users\Sundarapandiyan>jmeter -n -t D:\JMETER\apache-jmeter-3.1\bin\My Projects MyFirstUIRecordBadBoy.jmx -l \JMETER\apache-jmeter-3.1\bin\My Projects CSVSample_user.csv 'jmeter' is not recognized as an internal or external command, operable program or batch file.

3

3 Answers

8
votes

As Dave L mentioned, add the Jmeter installation bin directory to the system path using My Computer > properties > Advanced System settings > Environment variables > Under system variables, select PATH > Add D:\JMETER\apache-jmeter-3.1\bin to your path at the end.

Please note, windows only considers the jmeter.bat file even when you run jmeter. It won't run the plain jmeter file available under the installation path.

1
votes

To directly run a program on the command line it needs to be either included in the environment PATH; in the same folder; or specified by full path.

To use JMeter via command line you can either:

  • Add the folder containing JMeter to your PATH (see https://www.java.com/en/download/help/path.xml) for how to do this across Windows versions, it's quite generic despite saying JAVA)
  • Run it directly from the JMeter folder (in your case D:\JMETER\apache-jmeter-3.1), this is the easiest option for you.
    • You can do this by either Shift+Right Clicking in the folder & using 'Open command window here') or;
    • Changing to the directory via command line

You can change drive & directory on the command line using:

D:
cd D:\JMETER\apache-jmeter-3.1
1
votes

If we have space in folder name, the path will get break and you won't be able to run the file. To overcome this, please use double quotes in the full path. Example: C:\Users\Sundarapandiyan>jmeter -n -t "D:\JMETER\apache-jmeter-3.1\bin\My Projects" MyFirstUIRecordBadBoy.jmx -l "path_to_jtl_file"

And also add complete path of jmeter. example: C:\Users\Sundarapandiyan\Jmeter_folder\bin\jmeter -n -t [rest of the command]