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:
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.
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 Tutorial.
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.
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 )
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.
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.
@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.
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.