# Including shared pde files across projects

**URL:** <https://discourse.processing.org/t/including-shared-pde-files-across-projects/1701>\
**Category:** Development\
**Created:** [July 12, 2018, 3:49am UTC](https://discourse.processing.org/t/including-shared-pde-files-across-projects/1701 "2018-07-12T03:49:47Z")\
**Posts on this page:** 20\
**Page:** 2

<div class="post-metadata">

**Author:** ![malcolm\_gc](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/malcolm_gc/32/694_2.png) [@malcolm\_gc](https://discourse.processing.org/u/malcolm_gc)\
**Post date:** [July 14, 2018, 11:59pm UTC](https://discourse.processing.org/t/including-shared-pde-files-across-projects/1701/21 "2018-07-14T23:59:56Z")

</div>

for jfrajer

'C:\Users\mnmmc\Documents\Processing\libraries\>tree /a /f  
Folder PATH listing for volume OS  
Volume serial number is 3E47-3D32  
C:.  
| malcolm.jar  
|  
—Palette  
—library  
Palette.jar

tried adding both

import malcolm.Palette._;  
import static malcolm.Palette._;

as GoToLoop suggested but get

No library found for malcolm.Palette  
No library found for malcolm.Palette

neither one nor the other nor both work

checked my Preferences again C:\Users\mnmmc\Documents\Processing so it seems to me the libraries are in the correct spot and named correctly

.

---

<div class="post-metadata">

**Author:** ![malcolm\_gc](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/malcolm_gc/32/694_2.png) [@malcolm\_gc](https://discourse.processing.org/u/malcolm_gc)\
**Post date:** [July 15, 2018, 12:09am UTC](https://discourse.processing.org/t/including-shared-pde-files-across-projects/1701/22 "2018-07-15T00:09:30Z")

</div>

for GoToLoop

changed my PaletteJarSketch.pde to include both import lines and copied the Palette.jar from repo to libraries/Palette/library run the sketch

No library found for malcolm.Palette  
No library found for malcolm.Palette

so if this works for you is it some necessary environment setting that is not set on my PC

I have java/jre1.8.0\_31  
Processing is 3.3.7  
Sketchbook location C:\Users\mnmmc\Documents\Processing  
libraries are in that directory  
I am wearing my lucky shirt and have a 4 leaf clover on my desk

---

<div class="post-metadata">

**Author:** ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)\
**Post date:** [July 15, 2018, 12:18am UTC](https://discourse.processing.org/t/including-shared-pde-files-across-projects/1701/23 "2018-07-15T00:18:36Z")

</div>

If `C:\Users\mnmmc\Documents\Processing\` is the actual folder where all of your sketch folders are, the “Palette.jar” file should go into this path of folders: 🕵️‍♂️

`C:\Users\mnmmc\Documents\Processing\libraries\Palette\library\`

Make sure PDE isn’t running when you manually change anything inside your `C:\Users\mnmmc\Documents\Processing\` sketchbook path. 🙆‍♂️

---

<div class="post-metadata">

**Author:** ![malcolm\_gc](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/malcolm_gc/32/694_2.png) [@malcolm\_gc](https://discourse.processing.org/u/malcolm_gc)\
**Post date:** [July 15, 2018, 12:32am UTC](https://discourse.processing.org/t/including-shared-pde-files-across-projects/1701/24 "2018-07-15T00:32:32Z")

</div>

C:\Users\mnmmc\Documents\Processing\>tree +some files  
C:.  
├───libraries  
│ └───Palette  
│ └───library  
-------------------- Palette.jar  
├───project  
│ ├───PaletteJarCreationFolder  
│ │ └───Malcolm  
--------------------Palette.java  
│ ├───PaletteJarSketch  
---------------- PaletteJarSketch.pde

closed processing restarted

same result No library found for malcolm.Palette

thanks again to both of you,  
I am going out for a number of hours so I haven’t given up and will not be ignoring you just away.

---

<div class="post-metadata">

**Author:** ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)\
**Post date:** [July 15, 2018, 12:39am UTC](https://discourse.processing.org/t/including-shared-pde-files-across-projects/1701/25 "2018-07-15T00:39:24Z")

</div>

## “Sketchbook/”:

```auto
+---libraries
| \---Palette
| \---library
| Palette.jar
|
\---PaletteJarSketch
        PaletteJarSketch.pde

```

1. `"Sketchbook"/libraries/Palette/library/Palette.jar`
2. `"Sketchbook"/PaletteJarSketch/PaletteJarSketch.pde`

---

<div class="post-metadata">

**Author:** ![malcolm\_gc](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/malcolm_gc/32/694_2.png) [@malcolm\_gc](https://discourse.processing.org/u/malcolm_gc)\
**Post date:** [July 15, 2018, 6:28am UTC](https://discourse.processing.org/t/including-shared-pde-files-across-projects/1701/26 "2018-07-15T06:28:44Z")

</div>

Yep. That’s what I have got ! ! !

---

<div class="post-metadata">

**Author:** ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)\
**Post date:** [July 15, 2018, 7:41am UTC](https://discourse.processing.org/t/including-shared-pde-files-across-projects/1701/27 "2018-07-15T07:41:28Z")

</div>

So it didn’t work yet?! 👾 According to your `tree`: 🤔

> [@malcolm\_gc](#):
>
> ├───libraries  
> │ └───Palette  
> │ └───library  
> -------------------- Palette.jar

Appears to me the subfolder “library/” isn’t inside subfolder “Palette/”? 🙄

---

<div class="post-metadata">

**Author:** ![kfrajer](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kfrajer/32/196_2.png) [@kfrajer](https://discourse.processing.org/u/kfrajer)\
**Post date:** [July 15, 2018, 7:42am UTC](https://discourse.processing.org/t/including-shared-pde-files-across-projects/1701/28 "2018-07-15T07:42:21Z")

</div>

> [@kfrajer](#):
>
> Also, post the package line that you are using and the jar command to pack your library

You missed this info in your post for me.  
Also, open a cmd terminal, go to the folder that contain your jar file and type `pwd`. Paste here what you get.

Kf

---

<div class="post-metadata">

**Author:** ![malcolm\_gc](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/malcolm_gc/32/694_2.png) [@malcolm\_gc](https://discourse.processing.org/u/malcolm_gc)\
**Post date:** [July 15, 2018, 9:23am UTC](https://discourse.processing.org/t/including-shared-pde-files-across-projects/1701/29 "2018-07-15T09:23:49Z")

</div>

oops sorry

the package line is

package Malcolm;

I am using windows10 so pwd does not work but all of the files are in the sketchbook location  
C:\Users\mnmmc\Documents\Processing

the jar file is created in  
C:\Users\mnmmc\Documents\Processing\project\PaletteJarCreationFolder\>  
using the batch files provide by gotoloop which implement  
javac \*.java  
jar cf Palette.jar \*

---

<div class="post-metadata">

**Author:** ![akenaton](https://avatars.discourse-cdn.com/v4/letter/a/a88e4f/32.png) [@akenaton](https://discourse.processing.org/u/akenaton)\
**Post date:** [July 15, 2018, 9:47am UTC](https://discourse.processing.org/t/including-shared-pde-files-across-projects/1701/30 "2018-07-15T09:47:05Z")

</div>

@malcom\_gc===  
5’ to do that with Eclipse:

create new java project  
call it as you want  
inside it create a package, in this case i have named it “palette”  
inside this package create an interface, in this case i have called it palette also  
in this interface copy @GoToLoop code (Yellow and so on)  
now go to export  
choose export as jar  
save it where you want, it will be saved as “Palette.jar”  
in processing libraries create a new folder Palette  
inside it create library folder and put your jar inside it  
then run the code::

```auto

import palette.palette;
void setup(){
//does not claim about library
  background(0);
  fill(palette.YELLOW);///Yellow is defined inside the palette class
  ellipse(50,50,20,20);
  
}

```

O course if you dont have Eclipse you can use the jdk tools

- firstly javac
- secondly jar

PS: i dont know why but i cannot post images about the contents (from Pacifist) and the folders structure…

---

<div class="post-metadata">

**Author:** ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)\
**Post date:** [July 15, 2018, 10:15am UTC](https://discourse.processing.org/t/including-shared-pde-files-across-projects/1701/31 "2018-07-15T10:15:03Z")

</div>

> [@malcolm\_gc](#):
>
> The package line is: `package Malcolm;`

You can choose any name for the `package` statement, as long as you put the generated “.class” file inside folders w/ the exact corresponding name of that `package` when creating the “.jar” file! 😔

---

<div class="post-metadata">

**Author:** ![malcolm\_gc](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/malcolm_gc/32/694_2.png) [@malcolm\_gc](https://discourse.processing.org/u/malcolm_gc)\
**Post date:** [July 15, 2018, 10:17am UTC](https://discourse.processing.org/t/including-shared-pde-files-across-projects/1701/32 "2018-07-15T10:17:33Z")

</div>

akenaton

sorry I am not sure what the first two lines of your post indicate

@malcom\_gc=== \< maybe just to get my attention ??  
5’ to do that with Eclipse: \< I read 5’ five feet and isn’t Eclipse a different java package ? ? ?

I do appreciate your feedback.

I think your saying I should export this package into a jar file using Eclipse. Whilst I appreciate that some IDE might be able to do this, I would really like to understand why we haven’t been able to do it using the command lines of javac and jar

Because of the issues I have had in the posts above I have also been playing with the example for Animal and MammalInt in the following

[http://www.tutorialspoint.com/java/java\_packages.htm](http://www.tutorialspoint.com/java/java_packages.htm)  
describes how to compile to a class

https ://sites.google.com/site/alljavadevelopers/j2se-turorial/package (remove the space to make the link)work  
describes how to run the class  
mind you not sure whether your supposed to make a jar with this as neither link describes making a jar so did it anyway

and am finding that I can create the class and jar files but I can’t run them, the second link describes the commands to run the class (or maybe jar)

This seems to me to point to some environment issue that my system has. Adding another package (Eclipse) may just exacerbate my issues.

---

<div class="post-metadata">

**Author:** ![malcolm\_gc](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/malcolm_gc/32/694_2.png) [@malcolm\_gc](https://discourse.processing.org/u/malcolm_gc)\
**Post date:** [July 15, 2018, 10:35am UTC](https://discourse.processing.org/t/including-shared-pde-files-across-projects/1701/33 "2018-07-15T10:35:27Z")

</div>

As I said in the previous post I have been trying an example described in [http://www.tutorialspoint.com/java/java\_packages.htm](http://www.tutorialspoint.com/java/java_packages.htm) and https ://sites.google.com/site/alljavadevelopers/j2se-turorial/package (remove the space to create a link)

and, am having a similar problem so I do think that it might be some environment issue

the jpg below shows the files and commands and failures

 ![javaclass2](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/1X/95687bfb3e1b214d10e25b2dd1441fe4e9399a8f.jpg)

---

<div class="post-metadata">

**Author:** ![akenaton](https://avatars.discourse-cdn.com/v4/letter/a/a88e4f/32.png) [@akenaton](https://discourse.processing.org/u/akenaton)\
**Post date:** [July 15, 2018, 11:43am UTC](https://discourse.processing.org/t/including-shared-pde-files-across-projects/1701/34 "2018-07-15T11:43:13Z")

</div>

@malcolm\_gc===

i have spoken about Eclipse because exporting to .jar is included and so it is possible to get your .jar in 5’ (including the cut && copy from @GoToLoop.  
Now i have taken your animals example and made the same thing with command line  
from your image i see that you have successfully created your classes with javac; so the error is with your command for creating the .jar: supposing that you cd to “animals” where are your classes then in the terminal you write:  
jar cvf animals.jar \*  
with the c you obtain the jar as it is named which says the f  
with the v you get the verbose issue  
and normally after that you get a .jar  
i have got it…:10’ 😋

---

<div class="post-metadata">

**Author:** ![kfrajer](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kfrajer/32/196_2.png) [@kfrajer](https://discourse.processing.org/u/kfrajer)\
**Post date:** [July 15, 2018, 4:20pm UTC](https://discourse.processing.org/t/including-shared-pde-files-across-projects/1701/35 "2018-07-15T16:20:23Z")

</div>

This is addressing your MamalsInt case. Open a terminal in an empty folder. Copy the code below and paste it in the command window (In windows use `Ctrl+INS` key combination). it will run, create the java files, build their respective class files and run the code.

Another thing you can do is to copy this code into a bat file aka `run.bat`. To edit the file, right click on the file and choose **edit** instead of **open** , as the latter will execute the bat file. Then in the terminal window go to the folder containing the bat file, open a cmd window and type “run.bat” and it will execute.

Kf

P.S. Notice I have removed the definition of package above. If you use the package line, when java builds this file via javac, it creates a folder called “animals” and places the .class file there. When you build _MammalInt.java_ using the commands above, it won’t be able to see the Animal.class definition.

## File Run.bat

```nohighlight
REM Writes java file
REM
echo //package animals; > Animal.java
echo public interface Animal{ >> Animal.java
echo	public void eat(); >> Animal.java
echo	public void travels(); >> Animal.java
echo } >> Animal.java

REM Writes java file
REM
echo public class MammalInt implements Animal{ > MammalInt.java
echo	public void eat(){ System.out.println("Mammal eats"); } >> MammalInt.java
echo	public void travels(){System.out.println("Mammal travels");} >> MammalInt.java
echo	public static void main(String args[]){MammalInt m= new MammalInt(); m.eat();m.travels();} >> MammalInt.java
echo } >> MammalInt.java

REM Builds java files
REM
javac -d . Animal.java
javac -d . MammalInt.java

REM Runs the code
REM
java MammalInt

```

## Output of “java MammalInt”

```nohighlight
C:\Users\C\Pictures\Sell-June-2018\armband>java MammalInt
Mammal eats
Mammal travels

```

---

<div class="post-metadata">

**Author:** ![malcolm\_gc](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/malcolm_gc/32/694_2.png) [@malcolm\_gc](https://discourse.processing.org/u/malcolm_gc)\
**Post date:** [July 15, 2018, 9:10pm UTC](https://discourse.processing.org/t/including-shared-pde-files-across-projects/1701/36 "2018-07-15T21:10:56Z")

</div>

for kfrajer

the code did not run without some minor editing, for some reason the spaces or tabs between echo and public on a few lines were ignored making the line echopublic … so replaced the existing space/s with space in a text file added a fully qualified path to the javac line and copied and paste again

copied and paste the text into cmd shell works

ran the batch works

\*\*\*\* SUCCESS \*\*\*\*\* !!! woo hoo

the batch file created the two java files and and compiled the two classes

Animal.class  
MammalInt.class

then ran \>Java MammalInt

it returned

Mammal eats  
Mammal travels

That was an excellent example.

Now that I have something that works I hope that I can move that success to the other directories I will then be ecstatic

Thank you very much for your feedback and the batch file

---

<div class="post-metadata">

**Author:** ![malcolm\_gc](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/malcolm_gc/32/694_2.png) [@malcolm\_gc](https://discourse.processing.org/u/malcolm_gc)\
**Post date:** [July 15, 2018, 9:40pm UTC](https://discourse.processing.org/t/including-shared-pde-files-across-projects/1701/37 "2018-07-15T21:40:47Z")

</div>

for akenaton

5’ and 10’ means 5 seconds and 10 seconds perhaps ? ? ? ? ?

thanks for your post

C:\Users\mnmmc\Documents\Processing\project\animal\_pkg\animals

> “C:\Program Files\Java\jdk1.8.0\_101\bin\jar” cvf animals.jar \*  
> added manifest  
> adding: Animal.class(in = 138) (out= 119)(deflated 13%)  
> adding: MammalInt.class(in = 688) (out= 409)(deflated 40%)

the above creates animals.jar

“C:\Program Files\Java\jdk1.8.0\_101\bin\java” animals/MammalInt  
Error: Could not find or load main class animals.MammalInt

I don’t seem to have any trouble creating class and jar files just getting them to be useable

kfajers provided me a batch file that created an excellent animal and mammalint example with class files that are useable I created a jar from them but the found that the jar was not useable so am still struggling.

---

<div class="post-metadata">

**Author:** ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)\
**Post date:** [July 15, 2018, 9:44pm UTC](https://discourse.processing.org/t/including-shared-pde-files-across-projects/1701/38 "2018-07-15T21:44:23Z")

</div>

> [@kfrajer](#):
>
> If you use the `package` line, when java builds this file via `javac`, it creates a folder called “animals/” and places the “.class” file there.

When I 1st created the “Command.jar” I remember I used something to automatically place its “.class” compiled file in its correct folder. 🤪

But b/c this time I was more focused on the `jar` command than `javac`, I didn’t care to rediscover how I did it. So the trick is the argument `-d .`! 😯

Having `javac` placing the “.class” files in their correct folder on its own it’s 1 less vector for human errors. 😌

Like for example, creating the “.class” folders w/ the wrong capitalization (“Malcolm/” instead of “malcolm/”); thus failing to match the `package`’s exact name! 😰

Again, I’ve re-updated my “Processing\_Jar\_Creation” repo to use the new `-d .` argument for the `javac` command within the “.bat” file: 🙃

Actually, it’s a unified “.bat” now: [“CreateJarFile.bat”](https://github.com/GoToLoop/Processing_Jar_Creation/blob/master/PaletteJarCreationFolder/CreateJarFile.bat) → `javac -d . *.java && jar cf Palette.jar *` 😸

> **[GitHub - GoToLoop/Processing\_Jar\_Creation: Example for compiling a ".java"...](https://github.com/GoToLoop/Processing_Jar_Creation)**
>
> Example for compiling a ".java" file and package it as a ".jar" for Processing. - GitHub - GoToLoop/Processing\_Jar\_Creation: Example for compiling a ".java" file and p...

---

<div class="post-metadata">

**Author:** ![malcolm\_gc](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/malcolm_gc/32/694_2.png) [@malcolm\_gc](https://discourse.processing.org/u/malcolm_gc)\
**Post date:** [July 16, 2018, 1:49am UTC](https://discourse.processing.org/t/including-shared-pde-files-across-projects/1701/39 "2018-07-16T01:49:06Z")

</div>

for GoToLoop

Some success woo hoo

earlier today I changed the path on my machine I was having some issues having to add fully qualified paths to the jar javac commands I found that  
I had a path to C:\Program Files (x86)\Java\jre1.8.0\_31\bin  
changed it to C:\Program Files\Java\jdk1.8.0\_101\bin\  
I am not sure what effects this may have had on anything that has preceeded

anyway back to your post

Copied fresh all of files from the GitHub and loaded up Processing

ran PaletteJarSketch and it worked _ **BUT** _\* Processing STILL SAYS  
No library found for malcolm.Palette

so renamed all of the files so that they could not be used and finally ended up with just the  
PaletteJarSketch.pde and the  
C:\Users\mnmmc\Documents\Processing\libraries\Palette\library\Palette.jar and

ran it and I still got output with Processing saying No library found for malcolm.Palette

renamed the library Palette.j\_ar I now get no output and a much more verbose error message

The package “Malcolm” does not exist. You might be missing a library  
No library found for malcolm  
No library found for malcolm.Palette  
Libraries must be installed in a folder named ‘libraries’ inside the sketchbook folder (see the Preferences window).

So I am very happy that PaletteJarSketch is using the library Palette.jar and I now need to make sure that I can replicate this again and again AND understand what the hell I was doing wrong before.

Find it somewhat annoying that Processing is telling me there is no library when clearly it is being accessed - but I guess I don’t care as long as it works.

To all responders

I do appreciate all of the help provided by all responders but I must admit that I was getting a little swamped.

I shall now go back over all of this to determine why gotoloops repository stuff works now and why the earlier stuff didn’t.

Thanks again to all ! ! 😀

---

<div class="post-metadata">

**Author:** ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)\
**Post date:** [July 16, 2018, 2:02am UTC](https://discourse.processing.org/t/including-shared-pde-files-across-projects/1701/40 "2018-07-16T02:02:07Z")

</div>

> [@malcolm\_gc](#):
>
> Find it somewhat annoying that Processing is telling me there is no library when clearly it is being accessed…

You may try out your luck reporting it below: 😳

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

[Previous page](https://discourse.processing.org/t/including-shared-pde-files-across-projects/1701.md?page=1)

[Next page](https://discourse.processing.org/t/including-shared-pde-files-across-projects/1701.md?page=3)
