Installing pi4j

From Projects Wiki
Jump to: navigation, search

Installing pi4j

The Pi4J project is intended to provide a bridge between the native libraries and Java for full access to the Raspberry Pi.

Submitted by Ed Schoolcraft

#!/bin/bash

sudo mkdir -p /home/pi/downloads
cd /home/pi/downloads
sudo wget http://pi4j.googlecode.com/files/pi4j-1.0-SNAPSHOT.deb 
sudo dpkg -i pi4j-1.0-SNAPSHOT.deb 

sudo cat <<"DELIM"
------------------------------------------------
This installed the Pi4J libraries and example source files to: 
/opt/pi4j/lib 
/opt/pi4j/examples

When attempting to compile a Java program using the Pi4J libraries, make sure to include the Pi4J lib folder in the classpath: 
javac -classpath .:classes:/opt/pi4j/lib/'*' ... 

When attempting to start a Java program using the Pi4J libraries, make sure to include the Pi4J lib folder in the classpath: 
sudo java -classpath .:classes:/opt/pi4j/lib/'*' ... 

If you would like to explore the examples, you can compile all the examples with the following commands: 
cd /opt/pi4j/examples 
./build
------------------------------------------------
DELIM

exit