# Shared code between gateway and client

**URL:** <https://forum.inductiveautomation.com/t/shared-code-between-gateway-and-client/4977>\
**Category:** Module Development\
**Created:** [August 10, 2012, 2:52pm UTC](https://forum.inductiveautomation.com/t/shared-code-between-gateway-and-client/4977 "2012-08-10T14:52:04Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![systemparadox](https://avatars.discourse-cdn.com/v4/letter/s/b5e925/32.png) [@systemparadox](https://forum.inductiveautomation.com/u/systemparadox)\
**Post date:** [August 10, 2012, 2:52pm UTC](https://forum.inductiveautomation.com/t/shared-code-between-gateway-and-client/4977/1 "2012-08-10T14:52:04Z")

</div>

What is the recommended way to distribute shared code that needs to be available to both the gateway and the client?

It seems that the gateway doesn’t unpack pack200 (pack.gz) files. I would like to avoid having to have two copies of the shared code (a jar version and a pack200 version).

Thanks.

---

<div class="post-metadata">

**Author:** ![Travis.Cox](https://avatars.discourse-cdn.com/v4/letter/t/b9bd4f/32.png) [@Travis.Cox](https://forum.inductiveautomation.com/u/Travis.Cox)\
**Post date:** [August 10, 2012, 3:17pm UTC](https://forum.inductiveautomation.com/t/shared-code-between-gateway-and-client/4977/2 "2012-08-10T15:17:19Z")

</div>

The best way is to create a new project called YourModule\_Common. The gateway and client can both have it on their classpath. Then you just need to make a YourModule\_Common.jar that is both gateway and client scoped.

---

<div class="post-metadata">

**Author:** ![systemparadox](https://avatars.discourse-cdn.com/v4/letter/s/b5e925/32.png) [@systemparadox](https://forum.inductiveautomation.com/u/systemparadox)\
**Post date:** [August 13, 2012, 3:48pm UTC](https://forum.inductiveautomation.com/t/shared-code-between-gateway-and-client/4977/3 "2012-08-13T15:48:56Z")

</div>

Thanks for the reply. Adding a common jar shared across all scopes works.

Are there any downsides to this approach that I should be aware of? Possible implications on network traffic?  
What is the purpose of packaging up the client/designer-only jars into pack200 files?

Thanks.

---

<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:** [August 13, 2012, 4:02pm UTC](https://forum.inductiveautomation.com/t/shared-code-between-gateway-and-client/4977/4 "2012-08-13T16:02:45Z")

</div>

There’s not really any technical drawback to creating a common project/jar, we use that pattern extensively here as well.

The pack200 files are to reduce the size because they get sent on the wire to client/designers.

---

<div class="post-metadata">

**Author:** ![systemparadox](https://avatars.discourse-cdn.com/v4/letter/s/b5e925/32.png) [@systemparadox](https://forum.inductiveautomation.com/u/systemparadox)\
**Post date:** [August 13, 2012, 4:15pm UTC](https://forum.inductiveautomation.com/t/shared-code-between-gateway-and-client/4977/5 "2012-08-13T16:15:13Z")

</div>

Ok I’ll bear that in mind. It’s not a large module, so in practice the size probably won’t make much difference.

Many thanks.
