Pi4j with Eclipse

1,739 views
Skip to first unread message

Virendra Ashiwal

unread,
Apr 5, 2015, 8:35:18 AM4/5/15
to pi...@googlegroups.com
Hello..
I would like to run pi4j example "ControlGpioExample" in Raspberry as jar executable file created from Eclipse (On my Linux laptop).
I imported the pi4j to my project but when i run is as java application, it give me respective error. 

Error: 
<--Pi4J--> GPIO Blink Trigger Example ... started.
OpenJDK 64-Bit Server VM warning: You have loaded library /tmp/libpi4j.so which might have disabled stack guard. The VM will try to fix the stack guard now.
It's highly recommended that you fix the library with 'execstack -c <libfile>', or link it with '-z noexecstack'.
Apr 05, 2015 2:30:23 PM com.pi4j.util.NativeLibraryLoader load
SEVERE: Failed to load library [pi4j] using the System.load(file) method using embedded resource file: [jar:file:/home/viru/Downloads/pi4j-0.0.5/lib/pi4j-core.jar!/lib/soft-float/libpi4j.so]
Apr 05, 2015 2:30:23 PM com.pi4j.util.NativeLibraryLoader load
SEVERE: ERROR:  The native library [pi4j : libpi4j.so] could not be found in the JVM library path nor could it be loaded from the embedded JAR resource file; you may need to explicitly define the library path '-Djava.library.path' where this native library can be found.
Exception in thread "main" java.lang.UnsatisfiedLinkError: com.pi4j.wiringpi.Gpio.wiringPiSetup()I
at com.pi4j.wiringpi.Gpio.wiringPiSetup(Native Method)
at com.pi4j.io.gpio.RaspiGpioProvider.<init>(RaspiGpioProvider.java:47)
at com.pi4j.io.gpio.GpioFactory.getDefaultProvider(GpioFactory.java:102)
at com.pi4j.io.gpio.impl.GpioControllerImpl.<init>(GpioControllerImpl.java:67)
at com.pi4j.io.gpio.GpioFactory.getInstance(GpioFactory.java:85)
at BlinkTriggerGpioExample.main(BlinkTriggerGpioExample.java:53)

Ammar Bhutta

unread,
Aug 24, 2015, 5:10:44 PM8/24/15
to Pi4J
Were you able to figure it out- Here is my situation
I want to develop on eclipse and then transfer to Raspberry PI, I downloaded and referenced all the required libraries to setup the control example but getting the error message 
<--Pi4J--> GPIO Control Example ... started.
"Aug 24, 2015 4:03:19 PM com.pi4j.util.NativeLibraryLoader load
SEVERE: Unable to load [libpi4j.so] using path: [/lib/libpi4j.so]
java.lang.IllegalArgumentException: The path has to be absolute, but found: \lib\libpi4j.so" when compiling-


Can some one help here please

Stefan Schildbach

unread,
Aug 29, 2015, 5:11:09 AM8/29/15
to Pi4J
Hey,

you may want to take a look at the awesome Eclipse plug-in "LaunchPi" from Tsvetan Stoyanov.
It works like a charm and is really handy.

Good Luck,
Stefan

Robert Savage

unread,
Aug 29, 2015, 10:44:38 AM8/29/15
to Pi4J
FYI, The Pi4J library contains an embedded JNI native library that is extracted at runtime and used to communicate with the hardware on the Pi.  
This embedded native library is only usable on the Pi hardware and thus if you attempt to run a program that uses Pi4J on any computer besides the Pi, then it will fail.  
You can certainly do your development on your workstation and compile your Java project but to run it you must run it on the Pi itself.  

NetBean includes an easy way to do this by setting up the Pi as a remote system.

And as Stephan mentioned, there is the Eclipse plug-in "LaunchPi" from Tsvetan Stoyanov.

If you are getting this error message on the Pi hardware, then something else must be going wrong.  Are you compiling the Pi4J JAR yourself or are you using the pre-compiled version available for download?

Thanks, Robert

Annamalai Chockalingam

unread,
Nov 20, 2015, 2:49:12 AM11/20/15
to Pi4J
Hi there

You should try the Eclipse based IDE for RaspberryPI called as CodeRASPIde developed by ANCIT.
1. Project Wizard for Creating a new PI4J Project 
2. Java Project with PI4J Library added to ClassPath 
3. Configuration File for RasberryPI Programming with extn .picfg 
4. Modeling Editor for Editing the RasberryPI Model 
5. PIN Status Diagram indicating the USE of the PINs 
6. Code Visualizer to represent the current Flow Diagram of the Application under Development 
7. Remote Execution and Debug from Eclipse on RasberryPI using LaunchPI Plugins - 


Regards
Malai
Reply all
Reply to author
Forward
0 new messages