Basic Module to Import libraries

I am trying to include a Java library in Ignition, and believe I need to create a custom module to do so. How would one create such a module so we can add our own libraries as we see fit?

Well in some sense that’s exactly what a module is - adding your own libraries. To add external libraries (i.e. libraries that you didn’t write and compile yourself) it should simply be a matter of including those *.jar files alongside your module’s jar files in the *.modl file, and include them in your module descriptor.

What you do with those included libraries is of course a different matter, and that depends greatly on what the library is…

Well, I want to use the libraries inside of some app scripts. What would be the steps to accomplish this?

At the most basic, you’d package up the jar(s) into a module, including the jar in whatever scopes you want to use it from. Usually this will be either DC (designer/client), G (gateway) or DCG (all 3).

I suppose you could do no other work and then use:

[tt]from com.example import SomeClass[/tt]

Or you could be a bit nicer and write your own scripting module and merge it in somewhere like [tt]system.mystuff.*[/tt]

We probably should put together an example module that does this so you have a template to follow.

Sounds good, the template will be nice. I would like to add my own scripting functions. If I wanted to create a module with just libraries, would I just put all the libraries, with the appropriate ignition libraries in a zip and rename it to .modl?

That, and put a properly-formatted [tt]module.xml[/tt] file in there next to the jar files that lists the scopes for each jar file.