Java code compilation in .groovy files

Hey Guys,
Many thanks for answering my all previous questions guys, I’m learning to love Katalon studio really versatile tool.

Please see below example,
Method jsonExtracter() is not returning any STRING variable therefore it throws compilation error in .java file, however its not the case in .groovy files

public String jsonExtracter(String responseText) {  JSONObject obj = new JSONObject(responseText)         String authToken = obj.getString("authenticationToken")         System.out.println("this is authToken value from keyword : " + authToken) }

I have managed to get the jsonExtracter() java keyword working by changing the return type STRING to VOID in .groovy file and it works as expected,

Questions I have :

1. However do you think its possible to compile java code in groovy files?​
2. Katalon studio by default create .groovy extension files for keywords, is it possible to create .java files for keywords and call in the test scripts such as below, is this possible?

“CustomKeywords.‘public_api_keywords.JsonExtractor.jsonExtracter’(responseText)”

Would appreciate any help on this matter.

Thanks
Niro

I thought I didn’t use code formatter, I know one of your friendly staff already pointed out not to use any code formatter, I’ll double check next time.

jsonExtracter() method without code formatter

public String jsonExtracter(String responseText) {

JSONObject obj = new JSONObject(responseText)

    String authToken = obj.getString("authenticationToken")

    System.out.println("this is authToken value from keyword : " + authToken)

}