'Variable in library path with JMeter is not working

My JMeter plan config looks like this:

enter image description here

as you can see from the picture the mypath variable has a default value /somehwere which may change based on the machine that hosts JMeter.

So I added it as variable in the ${mypath}/bin below for Library.

However if I run a command like:

jmeter -n ... -Jmypath=/newpath/elsewhere

it is not working. Is there any way to put that path as variable?



Solution 1:[1]

I answer myself as the solution required is using the parameter -Juser.classpath=some_path which avoid the need to create an external parameter for that case.

Solution 2:[2]

You need to amend the variable using __P() function like:

${__P(mypath,/somepath)}

enter image description here

This way you will be able to override the value using -J command-line argument and if you don't provide the override value it will default to /somepath

More information:

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Randomize
Solution 2 Dmitri T