# My new tiny library "does not exist"

**URL:** <https://discourse.processing.org/t/my-new-tiny-library-does-not-exist/12989>\
**Category:** Libraries\
**Created:** [July 26, 2019, 12:44am UTC](https://discourse.processing.org/t/my-new-tiny-library-does-not-exist/12989 "2019-07-26T00:44:17Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![tove](https://avatars.discourse-cdn.com/v4/letter/t/cdc98d/32.png) [@tove](https://discourse.processing.org/u/tove)\
**Post date:** [July 26, 2019, 12:44am UTC](https://discourse.processing.org/t/my-new-tiny-library-does-not-exist/12989/1 "2019-07-26T00:44:17Z")

</div>

Hi folks –  
I’m trying to wrap some code up into a little personal library because I want to write a bunch of sketches that refer to it and I don’t want any of them to get out of sync if I need to change something. (Also, I’d like to distribute it to some labmates and make it very easy for them to use.)

So I finally managed to generate a .jar\*, I believe I’ve got it in the right place –`[sketchbook]/libraries/[name]/library/[name].jar`– and I’ve restarted Processing and even the whole computer. However, when I add `import [name];`, Processing tells me that the “package does not exist.” Interestingly, my library _does_ show up in the `import library` menu, but when I select it, only a blank line is added.

I’m suspicious that maybe I didn’t do something right in generating the .jar. My code is just a single class, in a single .java file which looks like this:

```auto
import processing.net.*; 
import processing.core.*;
import java.util.ArrayList;

public class Name {
    // lots of code here

    static public void main(String[] passedArgs) {
    String[] appletArgs = new String[] { "name" };
    if (passedArgs != null) {
      PApplet.main(PApplet.concat(appletArgs, passedArgs));
    } else {
      PApplet.main(appletArgs);
    }
  }
}

```

The .jar seems to work okay if I include it in the `code` directory of a given project, but I’d really like for it to be a centrally-accessible library for updating reasons.

Does anyone have any tips?

* * *
\*tips for anyone following in my footsteps, since I wasn't able to find some of this by googling:
- you can generate “non-Processing” Java (expand Processing’s convenience syntax and add that `static public void main(String[] passedArgs)` thing) by `file->export` to a standalone app, then “view package contents” to find the .java
- you’ll need to preface any Processing-specific functions with the class they come from, which is probably PApplet; e.g. “concat()” -\> “PApplet.concat()”
- in running the `javac`, you’ll need to refer to all the Processing jars you’re using in a classpath; for me, I’m using processing.core and [processing.net](http://processing.net), so that looks like `javac -d ./build -classpath /Applications/Processing/Processing.app/Contents/Java/core/library/core.jar:/Applications/Processing/Processing.app/Contents/Java/modes/java/libraries/net/library/net.jar *.java` There’s presumably a more elegant way to do this. 😛

---

<div class="post-metadata">

**Author:** ![kll](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kll/32/964_2.png) [@kll](https://discourse.processing.org/u/kll)\
**Post date:** [July 26, 2019, 2:00am UTC](https://discourse.processing.org/t/my-new-tiny-library-does-not-exist/12989/2 "2019-07-26T02:00:20Z")

</div>

possibly this helps:

> **[processing/processing](https://github.com/processing/processing/wiki/How-to-Install-a-Contributed-Library)**
>
> Source code for the Processing Core and Development Environment (PDE) - processing/processing

  

> **[processing/processing](https://github.com/processing/processing/wiki/Library-Basics)**
>
> Source code for the Processing Core and Development Environment (PDE) - processing/processing

---

<div class="post-metadata">

**Author:** ![tove](https://avatars.discourse-cdn.com/v4/letter/t/cdc98d/32.png) [@tove](https://discourse.processing.org/u/tove)\
**Post date:** [July 26, 2019, 5:02am UTC](https://discourse.processing.org/t/my-new-tiny-library-does-not-exist/12989/3 "2019-07-26T05:02:32Z")

</div>

I did read both of those – I wouldn’t have made it this far without them 🙂 – but I’m not seeing where I’m diverging from the instructions. I also tried to read through this forum thread: [Including shared pde files across projects](https://discourse.processing.org/t/including-shared-pde-files-across-projects/1701/8) (though I got a little lost in which things did and did not work) and I _think_ what I have follows the example in [https://github.com/GoToLoop/Processing\_Jar\_Creation](https://github.com/GoToLoop/Processing_Jar_Creation)

But I’m not in any sense a Java developer so it’s entirely possible I got the “building the .jar” part wrong, since that’s the part that’s glossed over in the Wiki entry. What I did was run, in a directory containing only `name.java`:

```auto
javac -d ./build -classpath /Applications/Processing/Processing.app/Contents/Java/core/library/core.jar:/Applications/Processing/Processing.app/Contents/Java/modes/java/libraries/net/library/net.jar *.java
cd build
jar cvf name.jar *

```

Do I maybe need other things in that directory when I make the .jar?

---

<div class="post-metadata">

**Author:** ![tove](https://avatars.discourse-cdn.com/v4/letter/t/cdc98d/32.png) [@tove](https://discourse.processing.org/u/tove)\
**Post date:** [July 26, 2019, 5:18am UTC](https://discourse.processing.org/t/my-new-tiny-library-does-not-exist/12989/4 "2019-07-26T05:18:43Z")

</div>

Aha, solved! I needed a `package name;` at the top of my .java.
