Processing.serial in BlueJ doesn't work


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:

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

Arduino arduino;

void setup() {
  size(300, 300);
  surface.setTitle("Hello world!");
  print("Available ports: ");
  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 tutorial.

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 Tutorial.

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

Maybe it can help out?


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.). :robot:

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

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

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

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

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.

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 :smiley: )


1 Like

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.

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

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.


1 Like

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:


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

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

@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.

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)
    public void settings()
        size(470, 200);
    public void setup()
        arduino = new Arduino(this, "/dev/cu.usbmodem1411", 57600);
    public void draw()
        for (int i = 0; i <= 13; i++) {
            if (values[i] == Arduino.HIGH)
            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;


1 Like

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).

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 on GitHub, so I swapped out the jSSC.jar for this one 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.

1 Like

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).