Ask a Question

How to call Java main method from Groovy Script in SoapUI


How to call Java main method from Groovy Script in SoapUI

Can someone please advice me how to call java main method along with argument from Groovy script.


Below are the steps which I have done

1) Write the code and eclipse under the main method 

2) Taking 4 parameters as input from the main method.

3) Run the class in eclipse and it's working fine.

4) Created the Jar file

5) Place in the bin/ext folder of ReadyAPI

6) Restart ReadyAPI


now the question is how can I call the main method from the groovy script. I try creating an object of the class and call method as same we call another method but it's not working. Is there any way to call the main method of the class.

Super Contributor

Did you import the class name where "idea" is package and "Execute" is class name:-

import com.idea.Execute


import com.idea.* //To import all the classes


Then try this:-


Execute ex = new Execute(); //Add parameters based on requirements.    //where call() is method of Execute class

If it solved you problem. Please accept as solution and don't forget to give kudos.

@avidCoder, I do not have any method in the class. It's the only main method I have in the class. I try doing this but it did not work

My java code looks like this

package project;

public class MyClass{

public static void main(String[] args) {
// performing some functionality here


Groovy script :

import project.MyClass;

MyClass sample = new MyClass();


It throws below error and I am not sure, Is this error coming because I am calling main method or any other issue


Super Contributor

Ok, Then this Java compatibility issue. What is your soapui version and the Java version?



Java Version : 1.8.0_181

Soupui Version: 2.3.0

Super Contributor

Also, the jar files you are using to execute the program in eclipse? Its problem with the extenal jars which you are using in eclipse. That jars may not be compatible with the ready API version.

Super Contributor

You remember, I had resolved the same error issue you were facing 1 month back related to running selenium code in Ready API -


Here, I gave you solution to use correct versions of ready API and selnium drivers. And finally it worked for you. Here, it is the same thing. You need to figure out. Else you can share the jars you are using in eclipse.

Champion Level 2

Why don't post exactly what you are using.

There is no way one gets the above error with mentioned code snippet.

Any ways, you can't call the main method on the object because that is static one.


@avidCoder, Yes, I think its same issue. Can you please let me know how to find compatibility between ready api, chromedriver version, and selenium as it is working fine in eclipse. 


The chrome version you have suggested before in here (, it just launches the chrome but it won't do anything further like searching for the particulate field and place the values etc..


I use my code with 2 chromedriver, one is suggested by you(2.26) and another one is is working fine with 2.38 but I think Ready API did not support 2.38 chrome version. As I use the same selenium jar in eclipse and ready api. It works in eclipse but not in readyapi.






@nmrao Below is the configuration I am using it.


Selenium jars



Ready API


Chrome Driver 



Chrome version

Version 65.0.3325.181 (Official Build) (64-bit)

Eclipse IDE

Version: Photon Release (4.8.0)


When I use the above selenium jar files with chromedriver 2.26, it just opens the chrome browser and does not do anything further - maybe the chrome version I am using is higher (I executed this on eclipse as well as ReadyAPI both). However, when I use chromedriver 2.38 with the same selenium jar files, it does work on eclipse but not on readyapi.

Showing results for 
Search instead for 
Did you mean: