Tag Archives: JAVA

IO PINS ON PI ZERO W

#74 Operating IO pins on the Raspberry PI Zero W

RaspberryPI Zero W pinout.

While Java programming I started to wonder if I could program a pi board with java. During my research I found out that it is possible and there is the Java ME version that is specifically designed to be used in embedded devices.

Java ME requires the creation of MIDlets which is quite complicated so I decided to start by using the Java SE version and the WiringPi library. I’m using a Raspberry Pi Zero W with DietPi installed.

STEPS

Make sure Java & the WiringPi library is installed on your DietPi.
Now open the dietpi-launcher.

sudo dietpi-launcher

Install Optimized Software > Browse Software > Java

Install Optimized Software > Browse Software > WiringPi

Setting up the APP
Compile the app with Eclipse.
Now build the .class files into a .jar file on windows.
This makes one .jar file and compresses it for easy distribution.
Make sure JavaSE1.8 is selected in Eclipse so that it can run on the PI’s openjdk version "1.8.0_212".

"C:\Program Files\Java\jdk-16.0.2\bin\jar" cvfm GPIOPinTestMain.jar manifest.txt GPIOPinTestMain.class

N.B The manifest file must have an open newline at the end!

Once the .jar file is created you can now upload it to the PI’s usr dir e.g "/usr/bin/a_java_app/gpiotest"

Install OPENSSH to allow Putty connections.

INSTALL ProFTPD so allow sftp://10.0.0.17 connections.

Download the code below