Question

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);
Was it helpful?

Solution 2

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);

OTHER TIPS

The Javascript kettle uses is Rhino. Rhino gives Javascript access to Java classes, but it's not completely transparent.

Check out the Rhino docs on Scripting Java.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top