Search code examples
javaperformanceshelljmeterbeanshell

Executing shell script containing java -jar Runtime.exec(), which java will it take, OS level or application level


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:

  1. I have a maven project, in which I specify java.
  2. The build runs the jmeter script which has beanshell executing the jar file.
  3. I also do some processing with the output of the jar execution(write specific output to another file, hence I wrote the shell script).
  4. I use this specific output, and use it to add to my request in jmeter before querying.

Any help is appreciated.


Solution

  • 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.