Search code examples
jarpentahokettle

Execute external jar file from pentaho


I am trying to execute a custom jar file from the modified javascript value. My Jar name is JsonParsing.jar which I have placed in lib folder. When I am trying to execute a method in the jar its giving me the error:

ReferenceError: "JsonParsing" is not defined.

Code Snippet:

var package1 = JsonParsing.parseJson.ParseJSON;
xyz=package1.processJson(data);

Solution

  • I have resolved the issue. I was missing the Packages thing while creating the instance. As I had a static method in my class I have to call it in the following way. (parseJson is my package name and ParseJSON is my class name) . Here Packages is the default class provided by Rhino

    var call = Packages.parseJson.ParseJSON; 
    xyz=call.processJson(data);
    

    If it is a non static method I had to create an object in the following way

    var call = new Pakages.parseJson.ParseJSON(); 
    xyz=call.processJson(data);