# Creating a basic module just to add a java class

**URL:** <https://forum.inductiveautomation.com/t/creating-a-basic-module-just-to-add-a-java-class/51428>\
**Category:** Module Development\
**Created:** [September 29, 2021, 4:08am UTC](https://forum.inductiveautomation.com/t/creating-a-basic-module-just-to-add-a-java-class/51428 "2021-09-29T04:08:18Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![juang](https://avatars.discourse-cdn.com/v4/letter/j/9dc877/32.png) [@juang](https://forum.inductiveautomation.com/u/juang)\
**Post date:** [September 29, 2021, 4:08am UTC](https://forum.inductiveautomation.com/t/creating-a-basic-module-just-to-add-a-java-class/51428/1 "2021-09-29T04:08:18Z")

</div>

I’m trying to add a jar file to ignition so that i can use it in scripting. I don’t have experience at all in this area, but i was able to download the examples from github and to create a module from that in Eclips IDE. but how can i add the jar file to the example project so that i can be able to call it later in ignition. i have a jposservice.jar and i want to be able to use in scripting

import java  
import jpos

What do i need to do to be able to add that to the project and create a module?

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [September 29, 2021, 1:29pm UTC](https://forum.inductiveautomation.com/t/creating-a-basic-module-just-to-add-a-java-class/51428/2 "2021-09-29T13:29:28Z")

</div>

This won’t work the way you’re hoping.

You can either add scripting functions that _use_ files in the JAR, by following the [scripting-function example](https://github.com/inductiveautomation/ignition-sdk-examples/tree/master/scripting-function), or you can skip the module all together and go a somewhat unsupported route where you place the JAR file(s) in `$IGNITION/lib/core/gateway` or `$IGNITION/lib/core/common` depending on what scopes you would need to access them.

---

<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:** [September 29, 2021, 5:15pm UTC](https://forum.inductiveautomation.com/t/creating-a-basic-module-just-to-add-a-java-class/51428/3 "2021-09-29T17:15:16Z")

</div>

If you only need a limited number of classes from the jar, you can construct a “script” module that has static public fields containing those classes, and mount it in the `system.` namespace. You’d have something like this as `StaticClasses.java`:

```auto
import jpos.some.path.to.package.SomeClass;

static public Class<?> SomeClass = SomeClass.class;

```

In your module hooks’ `initializeScriptManager()` methods, you’d have:

```auto
		manager.addScriptModule("system.jpos", StaticClasses.class, someDocProvider...);

```

Then you can instantiate `SomeClass` as `system.jpos.SomeClass(...)`. No import required.

---

<div class="post-metadata">

**Author:** ![bmusson](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bmusson/32/87530_2.png) [@bmusson](https://forum.inductiveautomation.com/u/bmusson)\
**Post date:** [September 29, 2021, 5:27pm UTC](https://forum.inductiveautomation.com/t/creating-a-basic-module-just-to-add-a-java-class/51428/4 "2021-09-29T17:27:33Z")

</div>

If you need to load a lot of classes, take a look at the solution I used load packages for my Orekit module (with the big disclaimer that this definitely doesn’t fall under proper use of the SDK).

```auto
ExtendedScriptManager extendedManager = new ClientExtendedScriptManager(manager);
extendedManager.addScriptPackage(
                new ScriptPackage.ScriptPackageBuilder()
                        .packagePath("org.orekit")
                        .blacklist(Collections.singletonList("org.orekit.compiler.plugin.DefaultDataContextPlugin"))
                        .classLoader(this.getClass().getClassLoader())
                        .build(),
                "system.orekit");

```

> <https://github.com/benmusson/ignition-orekit-module/blob/main/common/src/main/java/com/github/benmusson/ignition/orekit/common/script/ExtendedScriptManager.java>

---

<div class="post-metadata">

**Author:** ![juang](https://avatars.discourse-cdn.com/v4/letter/j/9dc877/32.png) [@juang](https://forum.inductiveautomation.com/u/juang)\
**Post date:** [September 30, 2021, 1:36am UTC](https://forum.inductiveautomation.com/t/creating-a-basic-module-just-to-add-a-java-class/51428/5 "2021-09-30T01:36:12Z")

</div>

thank you all. i will check all this out and try to see if my basic knowledge is enough to use this.
