Forum Discussion

pskitsme92's avatar
pskitsme92
Occasional Contributor
3 years ago
Solved

Calling Java function from groovy script

Hej 

We are working with testing API and GUI, for that we have implemented a Java util and aded the JAR file. We have managed to call the functions with simple types, and list f sting, now we have function wich needs both list of strings and list of integer something like

"

String [] lstString = ["str1","str2"]

Integer [] lstInteger = [1,2,3]

def util = new javaUtil()

util.ourfunction(lstString,lstInteger)

"

 

------------------------

in Java we have

 class javaUtil {

public ourfunction(String [] lstStr, int [] lstint) {...}

}

-----------

So the question is what did we miss we have other function calls  that worked well

BR Pierre

  • Thanks for reply, but we fixed the issue although it does not make much sense, the fix was in changing declaration from

    Integer [] lstint = [1,2,3] 

      the solution: 

    int [] lstint = [1,2,3] 

    Although as for my knowledge the int is casted to Integer !!

2 Replies

  • nmrao's avatar
    nmrao
    Champion Level 3
    Does same work from groovy script if you copy the class as well ?
    Does the class has any package?
    • pskitsme92's avatar
      pskitsme92
      Occasional Contributor

      Thanks for reply, but we fixed the issue although it does not make much sense, the fix was in changing declaration from

      Integer [] lstint = [1,2,3] 

        the solution: 

      int [] lstint = [1,2,3] 

      Although as for my knowledge the int is casted to Integer !!