Fork me on GitHub

Welcome to Pi4J!

This project is intended to provide a friendly object-oriented I/O API and implementation libraries for Java Programmers to access the full I/O capabilities of the Raspberry Pi platform. This project abstracts the low-level native integration and interrupt monitoring to enable Java programmers to focus on implementing their application business logic.

News / Announcements


Starting with the Pi4J 1.4 builds, the Pi4J project is prioritizing focus on providing Java programs access, control and communication with the core I/O capabilities of the Raspberry Pi platform. Earlier versions of Pi4J were perhaps too ambitious in scope and that led to significant project bloat to the point that the project was becoming unsustainable. The goal moving forward is to limit scope to that of the raw I/O capabilities of the Raspberry Pi platform and provide timely updates and releases for bug fixed and new RaspberryPi model introductions. Reducing the scope of the project should better serve the Java community for basic I/O access by reducing complexity.

The following features have been removed from the Pi4J library:

  • IO Expanders: IO expansion is still supported but concrete implementations should be provided outside the core Pi4J core project such that they can be maintained and extended independently.
  • Other Platforms: Other platforms such as Odroid, BananaPi, NanoPi, OrangePi, etc. have been removed and will no longer be supported. The challenge with supporting these additional platforms is that Pi4J depends on the underlying WiringPi project and WiringPi ports for these other platforms is not well supported by the various SoC vendors or community. The various WiringPi ports for these other platforms are also inconsistent causing inconsistent features and functionality of Pi4J. Additionally, regression testing of bug fixes and new features in Pi4J is compounded with each additional supported platform.
  • Components & Devices: Pi4J originally provided higher level interfaces for components and devices that provided an abstraction layer between real world devices (things) and lower-level I/O interfaces. While a noble goal, unfortunately this part of the project never received the attention and time that it deserved and never gained much adoption by the community. We are removing these to allow Pi4J to focus solely on the raw I/O supported by the Raspberry Pi platform.

New development and bug fixes will now be provided via the 2.0-SNAPSHOT builds and the latest development codebase is now maintained in the 'V2' branch.

Project Status

Please note that the Version 1.x codebase for this project is no longer being actively developed. The Version 1.x codebase will only be maintained and updated for major bug fixes. This codebase has been largely stable for several years and is compatible across a wide variety of Raspberry Pi SoCs and you are welcome to continue using it. However, for new projects, it is highly recommended to migrate to the Pi4J Version 2.x codebase.

Bug fixes are maintained in the 'master' branch in the Pi4J GitHub repository and SNAPSHOT builds are published in the Sonatype OSS repository.

Visit the Downloads page to download the latest Pi4J v1.x library builds.


  • Java 11 JRE/JDK - The Java 11 runtime environment must be installed and configured on your SoC platform.
    • This project requires Java 11 (JDK) to build; however, it fails to compile using the latest Oracle JDKs.
    • The project will successfully compile using OpenJDK, Liberica, Zulu and AdoptOpenJDK distributions.
  • WiringPi -The latest WiringPi library must be installed on your RaspberryPi.
    • The original WiringPi library has been **DEPRECATED** and is no longer maintained.
    • To support RaspberryPi 4B/400/CM4 and newer systems you must install the latest *unofficial* WiringPi version which is maintained here: (As of 2021-01-12, this is version 2.60.)

    See Install/Prerequisites and Dependencies for additional information.

Supported Hardware


  • Export & unexport GPIO pins
  • Configure GPIO pin direction
  • Configure GPIO pin edge detection
  • Control/write GPIO pin states
  • Pulse GPIO pin state
  • Read GPIO pin states
  • Listen for GPIO pin state changes (interrupt-based; not polling)
  • Automatically set GPIO states on program termination (GPIO shutdown)
  • Triggers for automation based on pin state changes
  • Send & receive data via RS232 serial communication
  • I2C Communication
  • SPI Communication
  • Extensible GPIO Provider interface to add GPIO capacity via expansion boards
  • Access system information and network information from the Raspberry Pi
  • Wrapper classes for direct access to WiringPi Library from Java

Getting Started

The simplest method to install Pi4J on your RaspberryPi is to execute the following command directly on your RaspberryPi.
curl -sSL | sudo bash

To get started using the Pi4J library, please see the following pages:


Review each of the following examples to explore the functionality provided by the Pi4j library.