Reputation: 2320
I am trying to execute a java jar from my jmeter tests via beanshell.
The approach I followed is to create a shell script, execute it through beanshell using Runtime.exec() function.
The question I have is whether execution of this shell script will take java from instance/host/OS level or it will be executed as part of current java that the application is using.
There could be open questions for which I want to provide an answer to before time:
Any help is appreciated.
Upvotes: 0
Views: 473
Reputation: 168122
Depending on how you run your application. If you just use
Runtime.getRuntime().exec("java -jar ....");
The Process instance will look for java
executable which is available in your OS PATH. If there will no be java
executable in the PATH - the call will fail.
Be aware that starting from JMeter 3.1 it is recommended to use JSR223 Test Elements and Groovy language for any form of scripting so consider migrating to Groovy on next available opportunity. For instance you can kick off the process and get the output as simple as:
String response = "your command".execute().text
Also instead of running your .jar in as separate process it might be better to add it to JMeter Classpath and call necessary functions directly from the Groovy code. See Apache Groovy - Why and How You Should Use It article for more information.
Upvotes: 0
Reputation: 91
In a way, both.
The shell script will be executed as part of your Java program, but it will be executed using the system's default Java executable unless you've specified a Java executable in the exec()
method call.
Upvotes: 1