Calling Java code from Mirth

mardi 27 janvier 2015

I've read some examples from Mirth regarding how to package java code and call it from Mirth. However, I don't seem to be able to do so. I'm using Mirth Connect 3.1.1.7461. Would you please help?



Here are the steps that I take.

- Create a package called comp1.package1.jar. Here is the code

==================

package comp1.package1;



public class Class1 {

public Class1(){

System.out.println("comp1.package1.Class1 constructor");

}



public void SayHello(){

System.out.println("comp1.package1.Class1 say hello");

}

}

====================



- put the jar file under C:\Program Files\Mirth Connect\custom-lib

- restart Mirth connect service

- create a CallJavaCode Channel with Source as JavaScript Reader

- here is the Mirth code



============================

try {

importPackage(Packages.comp1.package1);

} catch(e) {

logger.error('Error importing lib: ' + e)

}



try{

var class1 = new Class1();

class1.SayHello();

}catch(e) {

logger.error('Error calling function: ' + e)

}

============================



I don't seem to get any errors for importing package, even when I put in an invalid package name?! But always get the error when calling SayHello function.



Package and channel code are attached.



Thanks

Dan




Attached Files









File Type: xml CallJavaCode.xml (18.0 KB)
File Type: jar comp1.package1.jar (1.5 KB)







Calling Java code from Mirth

0 commentaires:

Enregistrer un commentaire