How to invoke a method from JAR file

Hello Team,

I have placed a Jar file in “\gatling-charts-highcharts-1.5.5\lib” directory

I am trying to invoke that method using Gatling through Scala

The scenario is, I want to do load test for that operation that Java method going to perform

Please let me know how can I do this. I tried searching over internet and couldn’t get right example

Thanks in advance

Manoj Kapuganti

What is this library doing? If it’s not a client library, you’d better user something more appropriate for microbenchmarking such as JMH.

Actually I am trying to do performance testing of REST service which uses Protocol buffer. We can get clients for Protocol buffer only in Java, C++ and Python. Hence I am using Java clients, means I am invoking REST service using Java.

I places those classes in the JAR file, I just want to invoke them to do performance testing

Please let me know if there is a way or at-least a work around

Manoj Kapuganti

You’ll need some good scala skills, as it would be like writing your own protocol support.

Sorry, may be I didn’t explain scenario properly

My requirement is, there is a class ‘TestClass’ with a method ‘TestMethod’ in a JAR file

I just want to call ‘TestMethod’ in my scala script

I tried placing that JAR file in \gatling-charts-highcharts-1.5.5\lib folder, also imported this class and added method call.

package Manoj
import com.excilys.ebi.gatling.core.Predef._
import com.excilys.ebi.gatling.http.Predef._
import com.excilys.ebi.gatling.jdbc.Predef._
import com.excilys.ebi.gatling.http.Headers.Names._
import akka.util.duration._
import bootstrap._
import assertions._
import test.TestClass

class PB extends Simulation {

val httpConf = httpConfig
.acceptEncodingHeader(“gzip, deflate”)
.userAgentHeader(“Mozilla/5.0 (Windows NT 6.1; WOW64; rv:19.0) Gecko/20100101 Firefox/19.0”)

val scn = scenario(“Scenario Name”)



I am getting following error on compilation

12:15:47.185 [ERROR] c.e.e.g.a.ZincCompiler$ - C:\Users\XXXXX\Desktop\gatling
-charts-highcharts-1.5.5\user-files\simulations\Manoj\PB.scala:28: value TestMethod is not a member of object test.TestClass

Also, let me know how I can I do load test by calling this method, means where I need to put yellow highligted method call

Manoj Kapuganti


This could only work if TestMethod was static, which it doesn’t seem to be?

val instance = new test.TestClass

No offense meant, but I’ll be honest: if you can’t fix this compiler error on your own, your scala skills are currently too low for the task.
First consider training yourself on Scala, there’s plenty of good introductions, such as



Thank you, I didn’t thought that I need to create an object and then it should be accessed, though that tool takes care of this part. Anyways its cool that we can do as in normal programming. In other tools like JMeter, we don’t need to create an object, just a selecting the method is enough. Just confused, sorry for bad question

~Manoj Kapuganti

objects bytecode is a bit complex, and simulations are loaded by reflection, so we need them to be regular classes.

Glad you could make it work,