# Manually import Java library, JDSP, and cannot use JDSP built-in functions

**URL:** <https://discourse.processing.org/t/manually-import-java-library-jdsp-and-cannot-use-jdsp-built-in-functions/46585>\
**Category:** Libraries\
**Created:** [June 21, 2025, 2:26pm UTC](https://discourse.processing.org/t/manually-import-java-library-jdsp-and-cannot-use-jdsp-built-in-functions/46585 "2025-06-21T14:26:17Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![jodoro](https://avatars.discourse-cdn.com/v4/letter/j/b5ac83/32.png) [@jodoro](https://discourse.processing.org/u/jodoro)\
**Post date:** [June 21, 2025, 2:26pm UTC](https://discourse.processing.org/t/manually-import-java-library-jdsp-and-cannot-use-jdsp-built-in-functions/46585/1 "2025-06-21T14:26:17Z")

</div>

The purpose of this code is to test whether the jdsp function can be called.  
I manually added the third-party library jdsp according to the method provided by the official.  
[How to Install a Contributed Library · processing/processing Wiki](https://github.com/processing/processing/wiki/How-to-Install-a-Contributed-Library)  
Here’s my test code, but it prompts after running

> ClassNotFoundException: uk.me.berndporr.iirj.Butterworth

```auto
import com.github.psambit9791.jdsp.misc.*;
import com.github.psambit9791.jdsp.io.*;
import com.github.psambit9791.jdsp.speech.*;
import com.github.psambit9791.jdsp.splines.*;
import com.github.psambit9791.jdsp.filter.*;
import com.github.psambit9791.jdsp.filter.adaptive.*;
import com.github.psambit9791.jdsp.windows.*;
import com.github.psambit9791.jdsp.transform.*;
import com.github.psambit9791.jdsp.signal.*;
import com.github.psambit9791.jdsp.signal.peaks.*;

double[] signal;
double[] result;
double[] result2;
void setup() {
  size(800, 400);
  
  int signalLength = 1000;
  signal = new double[signalLength];
  for (int i = 0; i < signalLength; i++) {
    double t = (double)i / 100; 
    signal[i] = Math.sin(2 * Math.PI * 1 * t) + 0.5 * Math.sin(2 * Math.PI * 20 * t);
  }
  
  // 应用低通滤波器
  int Fs = 100; 
  int order = 4; 
  int cutOff = 9; 
  
  Butterworth flt = new Butterworth(Fs);
  result = flt.lowPassFilter(signal, order, cutOff); //get the result after filtering
  result2 = flt.highPassFilter(signal, order, cutOff); //get the result after filtering
}

```

When I added `import uk.me.berndporr.iirj.*;`The error message becomes `The type Butterworth is ambiguous`  
I followed the official prompt to place the third-party library under the`sketch` → `libraries` → `JDSP` → `library` → `jdsp.jar`

---

<div class="post-metadata">

**Author:** ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)\
**Post date:** [June 21, 2025, 3:14pm UTC](https://discourse.processing.org/t/manually-import-java-library-jdsp-and-cannot-use-jdsp-built-in-functions/46585/2 "2025-06-21T15:14:19Z")

</div>

Hello @jodoro,

> [@jodoro](#):
>
> I manually added the third-party library jdsp

Please provide a link to the JDSP library you are using.

I did not find this in the Contribution manager for Processing 4.4.4

`:)`

---

<div class="post-metadata">

**Author:** ![jodoro](https://avatars.discourse-cdn.com/v4/letter/j/b5ac83/32.png) [@jodoro](https://discourse.processing.org/u/jodoro)\
**Post date:** [June 21, 2025, 3:51pm UTC](https://discourse.processing.org/t/manually-import-java-library-jdsp-and-cannot-use-jdsp-built-in-functions/46585/3 "2025-06-21T15:51:22Z")

</div>

ok.  
This is the official address of the JDSP library, [JDSP - Digital Signal Processing in Java](https://jdsp.dev/)  
a Java library for digital signal processing.  
Just a plain java library, not specifically designed for processing.  
This is explained in the old version of the official GitHub repository  
[How to Install a Contributed Library · processing/processing Wiki](https://github.com/processing/processing/wiki/How-to-Install-a-Contributed-Library)

> Non-Processing Libraries
> 
> Another example: you want to use the Apache Common Collections library, which is a plain Java library (ie. not designed for use with Processing). The zip file contains a folder named commons-collections-3.2.1 with various files in it, including one: commons-collections-3.2.1.jar
> 
> You have to create the libraries/ApacheCommonCollections/library folder (the middle name can vary, but must have only letters and numbers) where you put the jar file renamed along the folder name (here, ApacheCommonCollections.jar, then).
> 
> Alternatively, if you need this library for only one sketch, you can just drag’n’drop the jar file on the PDE, it will put it in a folder named `code` in the sketch folder (you can also create the folder manually and put the jar file there yourself). This also works, of course, for regular Processing libraries. This solution isn’t optimal if you plan to use the library in several sketches, as it will duplicate the library, taking up space and making difficult a possible upgrade.

---

<div class="post-metadata">

**Author:** ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)\
**Post date:** [June 21, 2025, 4:00pm UTC](https://discourse.processing.org/t/manually-import-java-library-jdsp-and-cannot-use-jdsp-built-in-functions/46585/4 "2025-06-21T16:00:29Z")

</div>

I downloaded v3.1.0 from the link you provided and could not find any JAR files.

It appears to be the source code only.

GitHub link:

> **[GitHub - psambit9791/jdsp: A Java Library for Digital Signal Processing](https://github.com/psambit9791/jdsp)**
>
> A Java Library for Digital Signal Processing

I rarely build from source and only if there are clear instructions.  
One of the more experienced users may be able to assist.

`:)`

---

<div class="post-metadata">

**Author:** ![jodoro](https://avatars.discourse-cdn.com/v4/letter/j/b5ac83/32.png) [@jodoro](https://discourse.processing.org/u/jodoro)\
**Post date:** [June 21, 2025, 4:38pm UTC](https://discourse.processing.org/t/manually-import-java-library-jdsp-and-cannot-use-jdsp-built-in-functions/46585/5 "2025-06-21T16:38:45Z")

</div>

Oh, sorry, I sent the wrong message earlier. The .jar file of the JDSP library is placed in the Maven Central Repository, and here is the correct address.  
Anyway, I really appreciate your response and help.  
If you want to try importing the JDSP library, the .jar file’s name should not contain numbers or symbols, such as “jdsp.jar”.

[jdsp.jar](https://mvnrepository.com/artifact/com.github.psambit9791/jdsp/3.1.0)

---

<div class="post-metadata">

**Author:** ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)\
**Post date:** [June 21, 2025, 5:28pm UTC](https://discourse.processing.org/t/manually-import-java-library-jdsp-and-cannot-use-jdsp-built-in-functions/46585/6 "2025-06-21T17:28:51Z")

</div>

[JDSP website](https://jdsp.dev/) states:

> JDSP is written purely in Java. It has dependencies on 3 core libraries: [Apache Commons Math](http://commons.apache.org/proper/commons-math/), [IIRJ](https://www.berndporr.me.uk/iir/site/) and [SSJ](https://umontreal-simul.github.io/ssj/) , all of which are also open source projects.

You need (at least for you sketch) these additional JAR files in your code folder in your sketch:

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/3/0/30443a8b2255362a6c1e43dfb95627b1998b1c2d.png)

I only needed the last import for your example:

```auto
//import com.github.psambit9791.jdsp.misc.*;
//import com.github.psambit9791.jdsp.io.*;
//import com.github.psambit9791.jdsp.speech.*;
//import com.github.psambit9791.jdsp.splines.*;
//import com.github.psambit9791.jdsp.filter.*;
//import com.github.psambit9791.jdsp.filter.adaptive.*;
//import com.github.psambit9791.jdsp.windows.*;
//import com.github.psambit9791.jdsp.transform.*;
//import com.github.psambit9791.jdsp.signal.*;
//import com.github.psambit9791.jdsp.signal.peaks.*;

import com.github.psambit9791.jdsp.filter.Butterworth; // Specific import for Butterworth

```

And voila!

You will have to add code to plot results:

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/c/5/c550f57c762a9e27a405a63b7d6878e4fc2eca16.png)

This was with some modifications to your code:

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/5/5/55ff4c63ffdc2f87a1a0c2ae38c5ed103faf4595.png)

I will leave it with you to find those jar files in here (I used these) or links on JDSP site:

- [Maven Central: com.github.psambit9791:jdsp](https://central.sonatype.com/artifact/com.github.psambit9791/jdsp)
- [Maven Central: org.apache.commons:commons-math3](https://central.sonatype.com/artifact/org.apache.commons/commons-math3/overview)
- [Maven Central: uk.me.berndporr:iirj](https://central.sonatype.com/artifact/uk.me.berndporr/iirj)

This was a fun and worthwhile!

I learned a lot!

`:)`

---

<div class="post-metadata">

**Author:** ![jodoro](https://avatars.discourse-cdn.com/v4/letter/j/b5ac83/32.png) [@jodoro](https://discourse.processing.org/u/jodoro)\
**Post date:** [June 22, 2025, 1:13am UTC](https://discourse.processing.org/t/manually-import-java-library-jdsp-and-cannot-use-jdsp-built-in-functions/46585/8 "2025-06-22T01:13:36Z")

</div>

Yes, my problem has been solved.  
Thank you, I am very touched by your warm help.  
In addition, your optimism and positive learning have forced me to reflect on my own perceptions, and you are my teacher to me.  
However, I still have a question. Why does using import all of jdsp prompt?

```auto
The type Butterworth is ambiguous

```

Like this.

```auto
import com.github.psambit9791.jdsp.misc.*;
import com.github.psambit9791.jdsp.io.*;
import com.github.psambit9791.jdsp.speech.*;
import com.github.psambit9791.jdsp.splines.*;
import com.github.psambit9791.jdsp.filter.*;
import com.github.psambit9791.jdsp.filter.adaptive.*;
import com.github.psambit9791.jdsp.windows.*;
import com.github.psambit9791.jdsp.transform.*;
import com.github.psambit9791.jdsp.signal.*;
import com.github.psambit9791.jdsp.signal.peaks.*;
//import com.github.psambit9791.jdsp.filter.Butterworth; // Specific import for Butterworth

```

---

<div class="post-metadata">

**Author:** ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)\
**Post date:** [June 22, 2025, 2:41am UTC](https://discourse.processing.org/t/manually-import-java-library-jdsp-and-cannot-use-jdsp-built-in-functions/46585/9 "2025-06-22T02:41:46Z")

</div>

You are welcome! I enjoyed this topic and helping out. Keeps the brain active!

There is a **Butterworth.class** in both the **jdsp** and the **iirj** libraries.  
You can look inside the JAR files with WinRAR.

The error **“The type Butterworth is ambiguous”** happens when **two or more classes with the same name (Butterworth)** are available and Java can’t tell which one to use.

Some of this is familiarity and experience in searching for answers and quickly iterating down to a solution.  
Not a pro at this but can navigate my way through these challenges.  
It is not always easy but gets easier and I enjoy the challenge.

All those imports may not be need for your example.  
I like to experiment and commented these out and included the one that was needed.  
Some of the gurus here may offer better insight.

`:)`

---

<div class="post-metadata">

**Author:** ![jodoro](https://avatars.discourse-cdn.com/v4/letter/j/b5ac83/32.png) [@jodoro](https://discourse.processing.org/u/jodoro)\
**Post date:** [June 22, 2025, 3:06am UTC](https://discourse.processing.org/t/manually-import-java-library-jdsp-and-cannot-use-jdsp-built-in-functions/46585/10 "2025-06-22T03:06:36Z")

</div>

Well, I see what you mean.  
I found out that there was **Butterworth** in the IIRJ library,  
it was my inexperience.  
Thank you for helping me with this.  
Some of your words and actions have left a deep impact on me.

---

<div class="post-metadata">

**Author:** ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)\
**Post date:** [June 22, 2025, 2:11pm UTC](https://discourse.processing.org/t/manually-import-java-library-jdsp-and-cannot-use-jdsp-built-in-functions/46585/11 "2025-06-22T14:11:52Z")

</div>

Hello again!

I came across this in the middle of the night:

_[https://stackoverflow.com/questions/35883253/how-to-use-jtransforms-library-with-processing-3](https://stackoverflow.com/questions/35883253/how-to-use-jtransforms-library-with-processing-3)_

Quote from above:

> Sometimes it helps to sleep on it! What seemed impossible last night was a breeze this morning.

That statement _ **resonates** _ with me and I often come back to a project the next day with solutions!

I remembered this in the middle of the night as well and this is why it all seemed so familiar to me:

> [@Type Serial is ambiguous](https://discourse.processing.org/t/type-serial-is-ambiguous/43584):
>
> I’m new to the Processing language. I am trying to run the code for the Arduino Networked Lamp as detailed in the Getting started with Arduino book. I’ve downloaded the program titled ex06 01 processing and I get the following error when I compile it: The type Serial is ambiguous on line 17: Serial port;

Additional references for future:

> **[Java Libraries](https://happycoding.io/tutorials/java/libraries)**
>
> Learn how to use Java libraries.

> **[How to Use Processing Libraries](https://happycoding.io/tutorials/processing/libraries)**
>
> Learn how to use libraries to expand what Processing can do.

This has all sparked my interest and I will certainly be exploring the topics in more depth in the future.

Thanks for all the kind words!

Have fun!

`:)`

---

<div class="post-metadata">

**Author:** ![svan](https://avatars.discourse-cdn.com/v4/letter/s/82dd89/32.png) [@svan](https://discourse.processing.org/u/svan)\
**Post date:** [June 22, 2025, 7:03pm UTC](https://discourse.processing.org/t/manually-import-java-library-jdsp-and-cannot-use-jdsp-built-in-functions/46585/12 "2025-06-22T19:03:03Z")

</div>

> [@glv](#):
>
> That statement _ **resonates** _ with me and I often come back to a project the next day with solutions!

The best cpu ever created is sitting on top of our shoulders.
