# Is possible Encapsulate a Function in Processing?

**URL:** https://discourse.processing.org/t/is-possible-encapsulate-a-function-in-processing/41524
**Category:** Development
**Created:** [March 30, 2023, 5:11am UTC](https://discourse.processing.org/t/is-possible-encapsulate-a-function-in-processing/41524 "2023-03-30T05:11:16Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Tibiscenas](https://avatars.discourse-cdn.com/v4/letter/t/ce73a5/32.png) [@Tibiscenas](https://discourse.processing.org/u/Tibiscenas)
#### Post date: [March 30, 2023, 5:11am UTC](https://discourse.processing.org/t/is-possible-encapsulate-a-function-in-processing/41524/1 "2023-03-30T05:11:16Z")

</div>

hi, can be convert a Simple Function in by a example a “Jar” that can be imported at compilation time ??

like a some found in Apache Org commons → math3, exec, io, etc.

example of function :

void adding(int x){  
int y;

y=10+x;  
println(y);  
}

---

<div class="post-metadata">

### Author: ![josephh](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/josephh/32/210_2.png) [@josephh](https://discourse.processing.org/u/josephh)
#### Post date: [March 30, 2023, 9:28am UTC](https://discourse.processing.org/t/is-possible-encapsulate-a-function-in-processing/41524/2 "2023-03-30T09:28:56Z")

</div>

Hi @Tibiscenas,

Yes it’s possible, you need to create a Java library and package it so it can be imported in another Java project.

One possible way to do this is to use Gradle:

[https://docs.gradle.org/current/samples/sample\_building\_java\_libraries.html](https://docs.gradle.org/current/samples/sample_building_java_libraries.html)

Note: you can’t just package a single function. Behind the scenes the Processing IDE wraps your code inside a class that has the methods `setup`, `draw` and your custom methods. 😉
