# Package Loader? like Class Loader with Reflect

**URL:** <https://forum.inductiveautomation.com/t/package-loader-like-class-loader-with-reflect/69810>\
**Category:** Module Development\
**Tags:** ignition79\
**Created:** [February 14, 2023, 1:11am UTC](https://forum.inductiveautomation.com/t/package-loader-like-class-loader-with-reflect/69810 "2023-02-14T01:11:27Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![jespinmartin1](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jespinmartin1/32/57175_2.png) [@jespinmartin1](https://forum.inductiveautomation.com/u/jespinmartin1)\
**Post date:** [February 14, 2023, 1:11am UTC](https://forum.inductiveautomation.com/t/package-loader-like-class-loader-with-reflect/69810/1 "2023-02-14T01:11:27Z")

</div>

Hi, need some help with this one. I've successfully imported some external classes through a module however there a lot of classes to manually reflect each one. Is there a thing like Package Loader?

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [February 14, 2023, 1:16am UTC](https://forum.inductiveautomation.com/t/package-loader-like-class-loader-with-reflect/69810/2 "2023-02-14T01:16:26Z")

</div>

You can just create public static final fields to hold the classes. See this example:

> [@Scripting Module - Some Question](https://forum.inductiveautomation.com/t/scripting-module-some-question/54862/4):
>
> Let me offer something simpler: public class Datasets { protected static final Pattern munger = Pattern.compile("\\W+"); public static String mungeColumnName(@ScriptArg("columnname") String columnName) { String munged = munger.matcher(columnName).replaceAll("\_"); if (Character.isDigit(munged.charAt(0))) return "\_"+munged; return munged; } public static final Class\<?\> TransientDataset = TransientDataset.class; } This shows a dead-simple class containing only statics to expose. O…

Then those names, in whatever `system....` namespace you specified, can be used without import.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [February 14, 2023, 1:17am UTC](https://forum.inductiveautomation.com/t/package-loader-like-class-loader-with-reflect/69810/3 "2023-02-14T01:17:23Z")

</div>

Wait! That was you I showed that to.

What more are you trying to do?

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [February 14, 2023, 1:21am UTC](https://forum.inductiveautomation.com/t/package-loader-like-class-loader-with-reflect/69810/4 "2023-02-14T01:21:54Z")

</div>

You could probably, if you _really_ wanted to, come up with some code generation tool to spit out a simple static class with all the appropriate public static final declarations, compiled together at build time.

Probably less work to just do it once in a while manually, though.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [February 14, 2023, 1:27am UTC](https://forum.inductiveautomation.com/t/package-loader-like-class-loader-with-reflect/69810/5 "2023-02-14T01:27:26Z")

</div>

> [@paul-griffith](#):
>
> code generation tool to spit out a simple static class with all the appropriate public static final declarations

Sounds awfully familiar....

> [@Machine Learning in Ignition using MATLAB](https://forum.inductiveautomation.com/t/machine-learning-in-ignition-using-matlab/56053/4):
>
> So, showing the whole thing is not on the table. Sorry. But one utility class I wrote will help you through the trickiest part of it: [FieldClassBuilder.java](https://www.automation-pros.com/streamer/FieldClassBuilder.java) (Note the MIT License.) This builder will assemble any desired classes from anywhere in your module, including any dynamically loaded classes you might access, into a generated class with a public static final field for each supplied class. The output from build() is suitable for use with ScriptManager.addScriptModule() in your various …

Yes, I do that. My Image Streamer module handles pretty much whatever version of OpenCV that's available. Intelligently produces usable jython classes and constants from what's in the OpenCV jar.

---

<div class="post-metadata">

**Author:** ![jespinmartin1](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jespinmartin1/32/57175_2.png) [@jespinmartin1](https://forum.inductiveautomation.com/u/jespinmartin1)\
**Post date:** [February 14, 2023, 1:35am UTC](https://forum.inductiveautomation.com/t/package-loader-like-class-loader-with-reflect/69810/6 "2023-02-14T01:35:40Z")

</div>

I want to import some classes of [org.apache.commons.imaging (Apache Commons Imaging 1.0-alpha3 API)](https://commons.apache.org/proper/commons-imaging/apidocs/org/apache/commons/imaging/package-summary.html), another: [org.apache.commons.imaging.color (Apache Commons Imaging 1.0-alpha3 API)](https://commons.apache.org/proper/commons-imaging/apidocs/org/apache/commons/imaging/color/package-summary.html) and another [org.apache.commons.imaging.common (Apache Commons Imaging 1.0-alpha3 API)](https://commons.apache.org/proper/commons-imaging/apidocs/org/apache/commons/imaging/common/package-summary.html) and some others but I constantly need to edit the module for new classes I suddenly need. I would like just to import the whole package and done.

---

<div class="post-metadata">

**Author:** ![jespinmartin1](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jespinmartin1/32/57175_2.png) [@jespinmartin1](https://forum.inductiveautomation.com/u/jespinmartin1)\
**Post date:** [February 14, 2023, 1:37am UTC](https://forum.inductiveautomation.com/t/package-loader-like-class-loader-with-reflect/69810/7 "2023-02-14T01:37:04Z")

</div>

Haha great memory!

---

<div class="post-metadata">

**Author:** ![jespinmartin1](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jespinmartin1/32/57175_2.png) [@jespinmartin1](https://forum.inductiveautomation.com/u/jespinmartin1)\
**Post date:** [February 14, 2023, 1:38am UTC](https://forum.inductiveautomation.com/t/package-loader-like-class-loader-with-reflect/69810/8 "2023-02-14T01:38:49Z")

</div>

mmm sound like a great solution. Any tool in mind? I was thinking do it manually with Java.
