14

I'm trying to run JMeter in non-gui mode (from the command line).

I've seen in a number of places, including the official docs, that this following command will do what I want:

jmeter -n –t test.jmx -l testresults.jtl

However, I get an illegal argument exception for the "t" argument. See below for my console output:

Console screenshot showing output from the command

Below is the output saved to jmeter.log:

2016/08/09 14:41:59 INFO  - jmeter.util.JMeterUtils: Setting Locale to en_GB 
2016/08/09 14:41:59 INFO  - jmeter.JMeter: Loading user properties from: C:\apache-jmeter-3.0_src\apache-jmeter-3.0\bin\user.properties 
2016/08/09 14:41:59 INFO  - jmeter.JMeter: Loading system properties from: C:\apache-jmeter-3.0_src\apache-jmeter-3.0\bin\system.properties 
2016/08/09 14:41:59 FATAL - jmeter.JMeter: An error occurred:  java.lang.IllegalArgumentException: Unknown arg: –t
    at org.apache.jmeter.JMeter.initializeProperties(JMeter.java:746)
    at org.apache.jmeter.JMeter.start(JMeter.java:385)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.apache.jmeter.NewDriver.main(NewDriver.java:259)
dahui
  • 2,128
  • 2
  • 21
  • 40
  • 2
    Place your script file "TwoMinuteTest.jmx" into your JMeter bin directory and then try this command: "jmeter -n –t TwoMinuteTest.jmx -l testresults.jtl" – Masud Jahan Aug 09 '16 at 14:07
  • 2
    I swear I tried this earlier, and it didn't work. I just tried it again, and it didn't work again. Then I removed the "-t" and typed it out again, and it worked!! Is there a subtle difference in typing a command and copying it from a text editor or something? – dahui Aug 09 '16 at 14:20
  • Stick this in an answer if you like and I'll mark it up when I can. – dahui Aug 09 '16 at 14:21

10 Answers10

28

So the issue was how I was getting the command into the command line.

When I copied and pasted my command, it was copied from a webpage, into notepad, and then into the command line. I wrongly assumed notepad would encode the correct character.

Just a bit confusing as the -n worked but not -t. Silly error!

dahui
  • 2,128
  • 2
  • 21
  • 40
3

Place your script file "TwoMinuteTest.jmx" into your JMeter bin directory and then try this command:

jmeter -n –t TwoMinuteTest.jmx -l testresults.jtl

Masud Jahan
  • 3,418
  • 2
  • 22
  • 35
  • Hi, thanks for the answer. I've tested this since and the issue occured when I tried to copy and paste the command into the console. – dahui Aug 11 '16 at 13:08
2

I just got the same error, and it turned out that instead of a regular hyphen (aka "minus sign"), the character was a en-dash, and they look similar enough for me not to notice.

Turns out that the Linux version of JMeter (or if it is Linux itself) is very picky, and only accepts the plain regular hyphen character. While the Windows version of JMeter handles both. I copy pasted from a command line example on a website, and I guess that person had run it on Windows and not tried it on Linux.

I think this was the same thing that happened to the original poster here. Posting this as an answer since it is still can happen, and no answer talked about the possibility that the wrong character was used.

j5423951
  • 133
  • 1
  • 12
1

You must keep your .jmx file in jmeter bin folder and you can change your log file location anywhere you wish.

jmeter -n –t TwoMinuteTest.jmx -l C:\users\desktop\Log.Txt -- Will create a text file as log.

jmeter -n –t TwoMinuteTest.jmx -l C:\users\desktop\Log.Csv -- Will create a Csv file as log.

jmeter -n –t TwoMinuteTest.jmx -l C:\users\desktop\Log.Xls -- Will create a Xls file as log.

If the log file is not there in the location, it will create a new file while running the test.

Aneesh PK
  • 11
  • 1
1

Open .bat file in notepad++ select encoding as Encode in UTF-8 from menu if your file is having any special character correct it using below format: jmeter -n –t "testscript.jmx" -l "results_test.jtl"

Amruta
  • 1,128
  • 1
  • 9
  • 19
0

Earlier my TimersTestPlan.jmx had a space , like this Timers TestPlan.jmx When I removed the space it worked for me in windows.

jmeter -n -t C:\FREESOFT\JmterPlanLoc\TimersTestPlan.jmx -l C:\FREESOFT\JmterPlanLoc\Export\Clreport.csv
Sameera De Silva
  • 1,722
  • 1
  • 22
  • 41
0

This Worked Perfectly:

jmeter -n -t "F:\WebsitePerformanceTest.jmx" -l "F:\TestResults.csv" -e -o "F:\Reports"
Adrian Mole
  • 49,934
  • 160
  • 51
  • 83
Sharma AK
  • 79
  • 1
  • 3
  • 2
    Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-ask). – Community Sep 18 '21 at 11:09
0

check-in your

  1. file extension example space, double dots
  2. Install JMeter plugin
  3. Java JDK and JMeter version miss-match.
Peter Csala
  • 17,736
  • 16
  • 35
  • 75
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Feb 28 '22 at 10:15
0

Instead of:

jmeter -n –t test.jmx -l testresults.jtl

You should use:

jmeter -n –t "test.jmx" -l "testresults.jtl"

This helped me a when getting

Unknown arg error level 1.

helvete
  • 2,455
  • 13
  • 33
  • 37
machete333
  • 11
  • 1
-1

Instead of:

jmeter -n –t test.jmx -l testresults.jtl

You should use:

jmeter -n –t "test.jmx" -l "testresults.jtl"
double-beep
  • 5,031
  • 17
  • 33
  • 41