First make sure that an existing pi4J folder/files does not exist on the file system:
sudo rm -r /opt/pi4j
cd ~
wget http://pi4j.googlecode.com/files/pi4j-0.0.4.zip << make sure to download the correct version
Execute the following commands to extract the zip contents and setup the correct permissions on these files.
(Note: make sure to use the correct version number based on your download in the commands below.)
sudo unzip pi4j-0.0.4.zip -d /opt
sudo mv /opt/pi4j-0.0.4/ /opt/pi4j
sudo mv /opt/pi4j/libs/ /opt/pi4j/lib
sudo chmod 777 /opt/pi4j/examples
sudo chmod 666 /opt/pi4j/examples/*
sudo chmod 777 /opt/pi4j/examples/build
Finally, if you want to you can build all the examples using the following command:
(Note: you must have a JDK installed.)
/opt/pi4j/examples/build