{"id":20427097,"url":"https://github.com/pi4j/pi4j-example-fatjar","last_synced_at":"2026-01-04T07:44:20.651Z","repository":{"id":148543621,"uuid":"407870091","full_name":"Pi4J/pi4j-example-fatjar","owner":"Pi4J","description":"Example project with results in a \"fat jar\", that contains classes from all the depending libraries, and, of course, the classes of this project.","archived":false,"fork":false,"pushed_at":"2024-03-21T12:30:18.000Z","size":297,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-01-25T17:30:21.520Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Pi4J.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-09-18T13:37:31.000Z","updated_at":"2023-02-07T17:51:27.000Z","dependencies_parsed_at":"2025-01-25T17:27:16.011Z","dependency_job_id":null,"html_url":"https://github.com/Pi4J/pi4j-example-fatjar","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Pi4J%2Fpi4j-example-fatjar","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Pi4J%2Fpi4j-example-fatjar/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Pi4J%2Fpi4j-example-fatjar/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Pi4J%2Fpi4j-example-fatjar/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Pi4J","download_url":"https://codeload.github.com/Pi4J/pi4j-example-fatjar/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244676451,"owners_count":20491828,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-15T07:18:54.716Z","updated_at":"2026-01-04T07:44:20.411Z","avatar_url":"https://github.com/Pi4J.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Pi4J V2 :: Minimal \"FAT JAR\" example application\n==================================================\n\nGitHub Actions: ![Maven build](https://github.com/pi4j/pi4j-example-fatjar/workflows/Maven/badge.svg)\n\nThis project contains a minimal example application which uses the Pi4J (V2) library and uses a digital output (LED) \nand digital input (push button). Full description is available on [the Pi4J website](https://pi4j.com/getting-started/minimal-example-application-fatjar/)\n\n## PROJECT OVERVIEW\n\nThe goal of the example project is to show how to set up a Pi4J Maven project for the Raspberry Pi to build a FatJAR with the Pi4J dependencies.\n\n## MAVEN SHADE PLUGIN\n\nBecause of the use of the ServiceLoader to dynamically load the plugins which are part of the project, all the files in `META-INF/services` need to be merged into one. This is not possible with the `Maven Assembly Plugin` that could be used with Pi4J V1.\n\nTo create a correct FAT JAR the `Maven Shade Plugin` needs to be used, with the additional \n[ServicesResourceTransformer](https://maven.apache.org/plugins/maven-shade-plugin/examples/resource-transformers.html#ServicesResourceTransformer). \nAs described on the Apache documentation page: *JAR files providing implementations of some interfaces often ship with \na META-INF/services/ directory that maps interfaces to their implementation classes for lookup by the service locator. \nTo relocate the class names of these implementation classes, and to merge multiple implementations of the same interface \ninto one service entry, the ServicesResourceTransformer can be used.*\n\n## WIRING\n\nThe application needs a LED connected on BCM 22 and button on BCM 24. \n\n![Breadboard schematics used in this example](assets/led-button_bb.png)\n\n## RUNTIME DEPENDENCIES\n\nThis project uses Pi4J V.2 which has the following runtime dependency requirements:\n- [**SLF4J (API)**](https://www.slf4j.org/)\n- [**SLF4J-SIMPLE**](https://www.slf4j.org/)\n\n## MAVEN BUILD DEPENDENCIES \u0026 INSTRUCTIONS\n\nThis project can be built with [Apache Maven](https://maven.apache.org/) 3.6 \n(or later) and Java 11 OpenJDK (or later). These prerequisites must be installed \nprior to building this project. The following command can be used to download \nall project dependencies and compile the Java module. You can build this \nproject on a development PC or directly on a Raspberry Pi with Java 11+.  \n\nBuild with:\n\n```\nmvn clean package\n```\n\nOnce the build is complete and was successful, you can find the compiled FAT JAR `pi4j-example-fatjar.jar` in the\n`target` directory. You can build directly on your Raspberry Pi or if you are developing on a different computer, copy the file \nto your Raspberry Pi with (in this example the RPi has the IP address 192.168.0.252):\n\n```\nscp target/pi4j-example-fatjar.jar pi@192.168.0.252://home/pi\n```\n\nOn the Raspberry Pi open a terminal, or via SSH from your PC, execute this command:\n\n```\n$ java -jar pi4j-example-fatjar.jar \n\n[main] INFO com.pi4j.util.Console - \n\n[main] INFO com.pi4j.util.Console - ************************************************************\n[main] INFO com.pi4j.util.Console - ************************************************************\n[main] INFO com.pi4j.util.Console - \n[main] INFO com.pi4j.util.Console -                   \u003c-- The Pi4J Project --\u003e                  \n[main] INFO com.pi4j.util.Console -                    Minimal Example project                  \n[main] INFO com.pi4j.util.Console - \n[main] INFO com.pi4j.util.Console - ************************************************************\n[main] INFO com.pi4j.util.Console - ************************************************************\n[main] INFO com.pi4j.util.Console - \n[main] INFO com.pi4j.Pi4J - New auto context\n[main] INFO com.pi4j.Pi4J - New context builder\n[main] INFO com.pi4j.runtime.impl.DefaultRuntime - Initializing Pi4J context/runtime...\n[main] WARN com.pi4j.runtime.impl.DefaultRuntime - Replacing provider DIGITAL_OUTPUT RaspberryPi Digital Output (GPIO) Provider with priority 0 with provider GpioD Digital Output (GPIO) Provider with higher priority 150\n[main] WARN com.pi4j.runtime.impl.DefaultRuntime - Replacing provider DIGITAL_INPUT RaspberryPi Digital Input (GPIO) Provider with priority 0 with provider GpioD Digital Input (GPIO) Provider with higher priority 150\n[main] INFO com.pi4j.library.gpiod.internal.GpioDContext - Using chip gpiochip0 pinctrl-bcm2711\n[main] INFO com.pi4j.platform.impl.DefaultRuntimePlatforms - adding platform to managed platform map [id=raspberrypi; name=RaspberryPi Platform; priority=5; class=com.pi4j.plugin.raspberrypi.platform.RaspberryPiPlatform]\n[main] INFO com.pi4j.runtime.impl.DefaultRuntime - Pi4J context/runtime successfully initialized.\n[main] INFO com.pi4j.util.Console - --------------------\n[main] INFO com.pi4j.util.Console - |  Pi4J PLATFORMS  |\n[main] INFO com.pi4j.util.Console - --------------------\n[main] INFO com.pi4j.util.Console - \nPLATFORMS: [1] \"Pi4J Runtime Platforms\" \u003ccom.pi4j.platform.impl.DefaultPlatforms\u003e \n    PLATFORM: \"RaspberryPi Platform\" {raspberrypi} \u003ccom.pi4j.plugin.raspberrypi.platform.RaspberryPiPlatform\u003e {Pi4J Platform for the RaspberryPi series of products.} \n[main] INFO com.pi4j.util.Console - \n[main] INFO com.pi4j.util.Console - ---------------------------\n[main] INFO com.pi4j.util.Console - |  Pi4J DEFAULT PLATFORM  |\n[main] INFO com.pi4j.util.Console - ---------------------------\n[main] INFO com.pi4j.util.Console - \nPLATFORM: \"RaspberryPi Platform\" {raspberrypi} \u003ccom.pi4j.plugin.raspberrypi.platform.RaspberryPiPlatform\u003e {Pi4J Platform for the RaspberryPi series of products.} \n[main] INFO com.pi4j.util.Console - \n[main] INFO com.pi4j.util.Console - --------------------\n[main] INFO com.pi4j.util.Console - |  Pi4J PROVIDERS  |\n[main] INFO com.pi4j.util.Console - --------------------\n[main] INFO com.pi4j.util.Console - \nPROVIDERS: [6] \"I/O Providers\" \u003ccom.pi4j.provider.impl.DefaultProviders\u003e \n    DIGITAL_INPUT: [1] \u003ccom.pi4j.io.gpio.digital.DigitalInputProvider\u003e \n       PROVIDER: \"GpioD Digital Input (GPIO) Provider\" {gpiod-digital-input} \u003ccom.pi4j.plugin.gpiod.provider.gpio.digital.GpioDDigitalInputProviderImpl\u003e {com.pi4j.plugin.gpiod.provider.gpio.digital.GpioDDigitalInputProviderImpl} \n    SERIAL: [1] \u003ccom.pi4j.io.serial.SerialProvider\u003e \n       PROVIDER: \"RaspberryPi Serial Provider\" {raspberrypi-serial} \u003ccom.pi4j.plugin.raspberrypi.provider.serial.RpiSerialProviderImpl\u003e {com.pi4j.plugin.raspberrypi.provider.serial.RpiSerialProviderImpl} \n    I2C: [1] \u003ccom.pi4j.io.i2c.I2CProvider\u003e \n       PROVIDER: \"RaspberryPi I2C Provider\" {raspberrypi-i2c} \u003ccom.pi4j.plugin.raspberrypi.provider.i2c.RpiI2CProviderImpl\u003e {com.pi4j.plugin.raspberrypi.provider.i2c.RpiI2CProviderImpl} \n    DIGITAL_OUTPUT: [1] \u003ccom.pi4j.io.gpio.digital.DigitalOutputProvider\u003e \n       PROVIDER: \"GpioD Digital Output (GPIO) Provider\" {gpiod-digital-output} \u003ccom.pi4j.plugin.gpiod.provider.gpio.digital.GpioDDigitalOutputProviderImpl\u003e {com.pi4j.plugin.gpiod.provider.gpio.digital.GpioDDigitalOutputProviderImpl} \n    SPI: [1] \u003ccom.pi4j.io.spi.SpiProvider\u003e \n       PROVIDER: \"RaspberryPi SPI Provider\" {raspberrypi-spi} \u003ccom.pi4j.plugin.raspberrypi.provider.spi.RpiSpiProviderImpl\u003e {com.pi4j.plugin.raspberrypi.provider.spi.RpiSpiProviderImpl} \n    ANALOG_OUTPUT: [0] \u003ccom.pi4j.io.gpio.analog.AnalogOutputProvider\u003e \n    ANALOG_INPUT: [0] \u003ccom.pi4j.io.gpio.analog.AnalogInputProvider\u003e \n    PWM: [1] \u003ccom.pi4j.io.pwm.PwmProvider\u003e \n      PROVIDER: \"RaspberryPi PWM Provider\" {raspberrypi-pwm} \u003ccom.pi4j.plugin.raspberrypi.provider.pwm.RpiPwmProviderImpl\u003e {com.pi4j.plugin.raspberrypi.provider.pwm.RpiPwmProviderImpl} \n[main] INFO com.pi4j.util.Console - \n[main] INFO com.pi4j.util.Console - -------------------\n[main] INFO com.pi4j.util.Console - |  Pi4J REGISTRY  |\n[main] INFO com.pi4j.util.Console - -------------------\n[main] INFO com.pi4j.util.Console - \nREGISTRY: [2] \"I/O Registered Instances\" \u003ccom.pi4j.registry.impl.DefaultRegistry\u003e \n    IO: \"Press button\" {button} \u003ccom.pi4j.plugin.gpiod.provider.gpio.digital.GpioDDigitalInput\u003e {DIN-24} \n    IO: \"DOUT-22\" {DOUT-22} \u003ccom.pi4j.plugin.gpiod.provider.gpio.digital.GpioDDigitalOutput\u003e {DOUT-22} \n[main] INFO com.pi4j.util.Console - \n[main] INFO com.pi4j.util.Console - LED high\n[main] INFO com.pi4j.util.Console - LED low\n[main] INFO com.pi4j.util.Console - LED high\n[main] INFO com.pi4j.util.Console - LED low\n[Pi4J.RUNTIME-1] INFO com.pi4j.util.Console - Button was pressed for the 1th time\n[main] INFO com.pi4j.util.Console - LED high\n[main] INFO com.pi4j.util.Console - LED low\n[main] INFO com.pi4j.util.Console - LED high\n[main] INFO com.pi4j.util.Console - LED low\n[Pi4J.RUNTIME-1] INFO com.pi4j.util.Console - Button was pressed for the 2th time\n[main] INFO com.pi4j.util.Console - LED high\n[main] INFO com.pi4j.util.Console - LED low\n[main] INFO com.pi4j.util.Console - LED high\n[main] INFO com.pi4j.util.Console - LED low\n[main] INFO com.pi4j.util.Console - LED high\n[Pi4J.RUNTIME-1] INFO com.pi4j.util.Console - Button was pressed for the 3th time\n[main] INFO com.pi4j.util.Console - LED low\n[main] INFO com.pi4j.util.Console - LED high\n[main] INFO com.pi4j.util.Console - LED low\n[Pi4J.RUNTIME-1] INFO com.pi4j.util.Console - Button was pressed for the 4th time\n[main] INFO com.pi4j.util.Console - LED high\n[main] INFO com.pi4j.util.Console - LED low\n[main] INFO com.pi4j.util.Console - LED high\n[main] INFO com.pi4j.util.Console - LED low\n[main] INFO com.pi4j.util.Console - LED high\n[Pi4J.RUNTIME-1] INFO com.pi4j.util.Console - Button was pressed for the 5th time\n[main] INFO com.pi4j.runtime.impl.DefaultRuntime - Shutting down Pi4J context/runtime...\n[main] INFO com.pi4j.plugin.gpiod.provider.gpio.digital.GpioDDigitalInput - Shutdown input listener for button\n[main] INFO com.pi4j.util.ExecutorPool - Shutting down executor pool Pi4J.RUNTIME\n[main] INFO com.pi4j.runtime.impl.DefaultRuntime - Pi4J context/runtime successfully shutdown. Dispatching shutdown event.\n...\n```\n\n## LICENSE\n\n Pi4J Version 2.0 and later is licensed under the Apache License,\n Version 2.0 (the \"License\"); you may not use this file except in\n compliance with the License.  You may obtain a copy of the License at:\n      http://www.apache.org/licenses/LICENSE-2.0\n\n Unless required by applicable law or agreed to in writing, software\n distributed under the License is distributed on an \"AS IS\" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n See the License for the specific language governing permissions and\n limitations under the License.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpi4j%2Fpi4j-example-fatjar","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpi4j%2Fpi4j-example-fatjar","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpi4j%2Fpi4j-example-fatjar/lists"}