# Processing.serial in BlueJ doesn't work

**URL:** https://discourse.processing.org/t/processing-serial-in-bluej-doesnt-work/3351
**Category:** Electronics (Arduino, etc.)
**Created:** [September 7, 2018, 4:27pm UTC](https://discourse.processing.org/t/processing-serial-in-bluej-doesnt-work/3351 "2018-09-07T16:27:04Z")
**Posts on this page:** 16
**Page:** 1

<div class="post-metadata">

### Author: ![Paul94](https://avatars.discourse-cdn.com/v4/letter/p/bbce88/32.png) [@Paul94](https://discourse.processing.org/u/Paul94)
#### Post date: [September 7, 2018, 4:27pm UTC](https://discourse.processing.org/t/processing-serial-in-bluej-doesnt-work/3351/1 "2018-09-07T16:27:04Z")

</div>

Hello,

Currently I am trying to use Processing in BlueJ. So far this works quite well - except for the serial interface to the Arduino. For this I have written the following code in Processing, which also works:

```auto
import processing.serial.*;
import cc.arduino.*;

Arduino arduino;

void setup() {
  size(300, 300);
  surface.setTitle("Hello world!");
  print("Available ports: ");
  println(Arduino.list());
  arduino = new Arduino(this, "COM8", 57600);
  System.out.println("Arduino connected!");
}

void draw() {
}

```

However, if I transfer this code to BlueJ, it will not work anymore and an error message will appear when executing the main function. I am following [this](https://processing.org/tutorials/eclipse/) tutorial.

 ![code_arduino_processing](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/9/916d5077f809a16e65acf055c4162d7d791d57d6.png)

DE:  
Derzeit versuche ich, Processing in BlueJ zu nutzen. Bis jetzt klappt das auch ganz gut - bis auf die serielle Schnittstelle zum Arduino. Dazu habe ich den oben stehenden Code in Processing geschrieben, der auch funktioniert. Übertrage ich jedoch diesen Code nach BlueJ, funktioniert das ganze nicht mehr und es erscheint die obige Fehlermeldung. Gefolgt bin ich [diesem](https://processing.org/tutorials/eclipse/) Tutorial.

---

<div class="post-metadata">

### Author: ![EnhancedLoop7](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/enhancedloop7/32/1040_2.png) [@EnhancedLoop7](https://discourse.processing.org/u/EnhancedLoop7)
#### Post date: [September 7, 2018, 4:35pm UTC](https://discourse.processing.org/t/processing-serial-in-bluej-doesnt-work/3351/2 "2018-09-07T16:35:52Z")

</div>

Is the Arduino library in your lib folder? Also, I looked online about your error, and found this:

> **[java.lang.unsatisfiedlinkerror – How to handle Unsatisfied Link Error](https://examples.javacodegeeks.com/java-basics/exceptions/java-lang-unsatisfiedlinkerror-how-to-handle-unsatisfied-link-error/)**
>
> In this tutorial we will discuss about Java’s UnsatisfiedLinkError and how to deal with it. The Unsa...

Maybe it can help out?

EnhancedLoop7

---

<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: [September 7, 2018, 4:53pm UTC](https://discourse.processing.org/t/processing-serial-in-bluej-doesnt-work/3351/3 "2018-09-07T16:53:29Z")

</div>

The Serial library, like any other library which deals w/ hardware (video, sound, etc.), is merely a wrapper for native files (".dll", “.so”, etc.) written in another system language (like C, C++, Rust, etc.). 🤖

You’ve gotta make sure your IDE has access to those system files, so the wrapper libraries can find them. 🧐

---

<div class="post-metadata">

### Author: ![Paul94](https://avatars.discourse-cdn.com/v4/letter/p/bbce88/32.png) [@Paul94](https://discourse.processing.org/u/Paul94)
#### Post date: [September 8, 2018, 6:05pm UTC](https://discourse.processing.org/t/processing-serial-in-bluej-doesnt-work/3351/4 "2018-09-08T18:05:58Z")

</div>

Thank you! How can I do that in this case?

---

<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: [September 8, 2018, 6:17pm UTC](https://discourse.processing.org/t/processing-serial-in-bluej-doesnt-work/3351/5 "2018-09-08T18:17:11Z")

</div>

Since I don’t have BlueJ, I dunno. 😖  
But you can take a look at PDE’s Serial library folder: 😳

_ **"PDE Install Folder"/modes/java/libraries/serial/library/** _

---

<div class="post-metadata">

### Author: ![Paul94](https://avatars.discourse-cdn.com/v4/letter/p/bbce88/32.png) [@Paul94](https://discourse.processing.org/u/Paul94)
#### Post date: [September 8, 2018, 8:48pm UTC](https://discourse.processing.org/t/processing-serial-in-bluej-doesnt-work/3351/6 "2018-09-08T20:48:12Z")

</div>

I moved a copy of the folder _ **"PDE Install Folder"/modes/java/libraries/serial** _ to  
_**C:/Users/[myname]/Documents/BlueJ**_. So BlueJ has access to it. But it doesn’t change anything.

---

<div class="post-metadata">

### Author: ![EnhancedLoop7](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/enhancedloop7/32/1040_2.png) [@EnhancedLoop7](https://discourse.processing.org/u/EnhancedLoop7)
#### Post date: [September 8, 2018, 10:20pm UTC](https://discourse.processing.org/t/processing-serial-in-bluej-doesnt-work/3351/7 "2018-09-08T22:20:43Z")

</div>

So to add a library in BlueJ, what you do first is go to where you installed it. C Drive, D Drive, or wherever it is, then Program Files. After that, you go to the **BlueJ** folder, and then click on **lib** then after that, you click on **userlib** and you add in your library to there.

After that, you can go into the BlueJ application, go to your current project, go to the **Tools** tab, scroll down to and click on **Preferences** , and then go to the **Libraries** tab. There, click on **Add** , and you find your library and add it in. Then you should be good to go!

Hopefully this helps, (took me a couple hours to figure out the first time I did it on BlueJ. Yes, I am slow 😃 )

EnhancedLoop7

---

<div class="post-metadata">

### Author: ![Paul94](https://avatars.discourse-cdn.com/v4/letter/p/bbce88/32.png) [@Paul94](https://discourse.processing.org/u/Paul94)
#### Post date: [September 9, 2018, 5:14am UTC](https://discourse.processing.org/t/processing-serial-in-bluej-doesnt-work/3351/8 "2018-09-09T05:14:22Z")

</div>

Of course I also tried that. If I move the serial.jar file to userlib the serial.jar will be marked as ‘loaded’ in BlueJ. But if I run my program now the above error appears.  
So I’ve tried to copy the whole folder ‘serial’ to make BlueJ have access to other files of the library that are needed (like GoToLoop wrote), e.g. the dll files of the inner folders. If I do this the library won’t even be loaded by BlueJ.

---

<div class="post-metadata">

### Author: ![Paul94](https://avatars.discourse-cdn.com/v4/letter/p/bbce88/32.png) [@Paul94](https://discourse.processing.org/u/Paul94)
#### Post date: [September 12, 2018, 5:20am UTC](https://discourse.processing.org/t/processing-serial-in-bluej-doesnt-work/3351/9 "2018-09-12T05:20:30Z")

</div>

Doesn’t anyone have a idea what I can do?

---

<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: [September 12, 2018, 6:08am UTC](https://discourse.processing.org/t/processing-serial-in-bluej-doesnt-work/3351/10 "2018-09-12T06:08:09Z")

</div>

If you open one of the examples provided by Processing (_File\>\>Examples_ then go to _Libraries\>\>Serial_), you can export it. This will produce an application with the required java code to run your application. You can also find a src and lib folder. If you check inside that library folder, you will see all the jar files required to run your application. Those jars need to be made available to BlueJ and properly added to the building process. I am not familiar with BlueJ myself, but hopefully this helps.

Kf

---

<div class="post-metadata">

### Author: ![Paul94](https://avatars.discourse-cdn.com/v4/letter/p/bbce88/32.png) [@Paul94](https://discourse.processing.org/u/Paul94)
#### Post date: [September 12, 2018, 5:44pm UTC](https://discourse.processing.org/t/processing-serial-in-bluej-doesnt-work/3351/11 "2018-09-12T17:44:32Z")

</div>

> [@kfrajer](#):
>
> If you open one of the examples provided by Processing ( _File\>\>Examples_ then go to _Libraries\>\>Serial_ ), you can export it.

I use the arduino library for communicating with the arduino. So I did this step with an example of ‘Arduino (Firmata)’.

BlueJ has access to the following libraries:

![Screenshot%20(29)](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/6/6e4d8c99648a44af0b97d58d4b14948df4c2bef2.png)

But it does still not work. I don’t know what I do wrong.

---

<div class="post-metadata">

### Author: ![Paul94](https://avatars.discourse-cdn.com/v4/letter/p/bbce88/32.png) [@Paul94](https://discourse.processing.org/u/Paul94)
#### Post date: [September 14, 2018, 7:59pm UTC](https://discourse.processing.org/t/processing-serial-in-bluej-doesnt-work/3351/12 "2018-09-14T19:59:09Z")

</div>

Now I have tried the same in eclipse - and it also does not work.

---

<div class="post-metadata">

### Author: ![mcintyre](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/mcintyre/32/14561_2.png) [@mcintyre](https://discourse.processing.org/u/mcintyre)
#### Post date: [September 15, 2018, 8:04pm UTC](https://discourse.processing.org/t/processing-serial-in-bluej-doesnt-work/3351/13 "2018-09-15T20:04:39Z")

</div>

@Paul94 I was able to get the _arduino\_example_ sketch running in BlueJ after some tinkering. Did this with a Macbook Pro and an Adafruit FLORA running the _StandardFirmata_ Arduino sketch.

I exported the slightly modified _flora\_blink_ sketch from Processing as @kfrajer suggested, then copied the Java folder from that package to a convenient location on my filesystem. In BlueJ, I added all of the _.jar_ files except for _flora\_blink.jar_ before restarting the IDE. The code below enables me to click a square and blink the FLORA’s onboard LED.

 ![bluej_config](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/d/d7d0e6d2fef8912650ed289e51345b43d0e6dbb5.png)

```auto
import processing.core.PApplet;
import processing.serial.*;
import cc.arduino.*;

public class P5 extends PApplet
{
    Arduino arduino;

    int off = color(4, 79, 111);
    int on = color(84, 145, 158);

    int[] values = { Arduino.LOW, Arduino.LOW, Arduino.LOW, Arduino.LOW,
 Arduino.LOW, Arduino.LOW, Arduino.LOW, Arduino.LOW, Arduino.LOW,
 Arduino.LOW, Arduino.LOW, Arduino.LOW, Arduino.LOW, Arduino.LOW };

    public static void main(String[] args)
    {
        PApplet.main("P5");
    }
    
    public void settings()
    {
        size(470, 200);
    }
    
    public void setup()
    {
        arduino = new Arduino(this, "/dev/cu.usbmodem1411", 57600);
    }
    
    public void draw()
    {
        background(off);
        stroke(on);
  
        for (int i = 0; i <= 13; i++) {
            if (values[i] == Arduino.HIGH)
                fill(on);
            else
                fill(off);
      
            rect(420 - i * 30, 30, 20, 20);
        }
    }
    
    public void mousePressed()
    {
        int pin = (450 - mouseX) / 30;
  
        // Toggle the pin corresponding to the clicked square.
        if (values[pin] == Arduino.LOW) {
            arduino.digitalWrite(pin, Arduino.HIGH);
            values[pin] = Arduino.HIGH;
         } else {
             arduino.digitalWrite(pin, Arduino.LOW);
             values[pin] = Arduino.LOW;
         }
     }
}

```

![flora_blink](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/e/e16428551b296803966d75f4a22a2cd550b29d65.png)

---

<div class="post-metadata">

### Author: ![Paul94](https://avatars.discourse-cdn.com/v4/letter/p/bbce88/32.png) [@Paul94](https://discourse.processing.org/u/Paul94)
#### Post date: [September 15, 2018, 8:58pm UTC](https://discourse.processing.org/t/processing-serial-in-bluej-doesnt-work/3351/14 "2018-09-15T20:58:56Z")

</div>

Thank you for your detailed reply! I followed your instructions but it does still not work. I think I don’t need the four last libraries (pi4j…) because they are only needed if I run the program on a Raspberry?  
BlueJ has access to all the libraries you posted (the version for windows instead of macOS).

---

<div class="post-metadata">

### Author: ![mcintyre](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/mcintyre/32/14561_2.png) [@mcintyre](https://discourse.processing.org/u/mcintyre)
#### Post date: [September 16, 2018, 12:18am UTC](https://discourse.processing.org/t/processing-serial-in-bluej-doesnt-work/3351/15 "2018-09-16T00:18:45Z")

</div>

Those last four libraries are part of BlueJ (haven’t looked them up myself). I just gave this a go on a laptop running Windows 10 and ran into the same error you encountered. Then I came across [this issue](https://github.com/scream3r/java-simple-serial-connector/issues/97) on GitHub, so I swapped out the _jSSC.jar_ for [this one](https://javalibs.com/artifact/org.scream3r/jssc) and it worked! When you run the example program, it should create a folder containing the _.dll_ in your home directory - something like C:\Users\you\.jssc\windows\jSSC-2.8\_x86.dll.

---

<div class="post-metadata">

### Author: ![Paul94](https://avatars.discourse-cdn.com/v4/letter/p/bbce88/32.png) [@Paul94](https://discourse.processing.org/u/Paul94)
#### Post date: [September 17, 2018, 5:35am UTC](https://discourse.processing.org/t/processing-serial-in-bluej-doesnt-work/3351/16 "2018-09-17T05:35:32Z")

</div>

Thank you! Now it works fine.

By the way I need to read and weite XML files, but this also does not work (actually the XML class is in core.jar so I wonder why it doesn’t work).
