Tagged "Tutorial"

Template project to build a JavaFX application as a JAR with dependencies with Maven

Recently, I was asked what the best way is to build a Fat JAR (a JAR with all dependencies) using Maven. Therefore, I created a GitHub project javafx-jar-template that you can use as a starting point. It contains a small JavaFX demo application with the TilesFX dependency and the necessary plugins in the pom.xml file.

Deep dive into bits, bytes, shorts, ints, longs, signed, and unsigned with Java

On the Pi4J discussion list, someone recently asked what the best and easiest way is in Java to convert a byte value. In Java, there is no distinction between signed and unsigned bytes, which can be confusing. My book “Getting Started with Java on the Raspberry Pi” contains an explanation about this, and I am happy to share it in this post with some more info and code examples…

JavaFX with Kotlin versus Java

Recently I have been experimenting with the combination of JavaFX and Kotlin. As Kotlin also runs on the Java Virtual Machine (JVM) and is a very close sister of Java, the switch is straightforward. I’m not making full use of what Kotlin can offer (non-blocking coroutines for example) as this is still a learning path for me… But I want to show you in this tutorial the difference in code style.

Example Java Application with Embedded Jetty and a htmx Website

I was experimenting with a Java application that can act as a web server and includes the user interface HTML-files that get modified with htmx, to replace certain parts of the HTML with other ones created in Java. I found it pretty hard to understand how to configure the embedded Jetty webserver, but as always with Java libraries, it’s pretty easy once you understand how to do it ;-) I decided to share my example, so you don’t need to go through the same search if you want to use the same approach…

Search in Documentation with a JavaFX ChatGPT-like LangChain4j Application

At the Fosdem conference in Brussels on February 3rd, I gave a presentation about using an existing documentation set as the data for a ChatGPT-like application, created with JavaFX and LangChain4J. The video and links of that presentation are available here, and this post is a more detailed explanation of that application.

Controlling LED strips with Java

One of the most “fancy” electronic components is definitely a LED strip. It’s really cool to control a long strip of lights with only a few lines of code… But, there is a problem. The timing of the signals is crucial to reliably control these strips. Both Python and Java on a Raspberry Pi can struggle with these timings as they are running on Linux, a non-real-time operating system. So, for instance, pauses in the garbage collection of the Java virtual machine, or any glitch in the operating system can cause unexpected effects on the LED strips. That’s why in most projects, a microcontroller (Arduino, Raspberry Pi Pico, ESP32,…) is used to drive the LED strip. In my search for a good solution to use LED strips with Java, I stumbled on the Pixelblaze Output Expander. This small device is controlled through a serial interface, and handles the control of the LED strip. As it turns out, this is a perfect solution to offload the timing-critical operations from the Raspberry Pi and have reliable output on a LED strip.

Reading the temperature, humidity, and pressure from a BME280 Sensor with Java, Pi4J, I2C, SPI, and JBang

To make it as easy as possible to get started with Java on the Raspberry Pi to interact with electronic components, I started a new section on the Pi4J website with JBang examples.

Using the Raspberry Pi Autofocus Camera Module 3 as HDMI camera

More than two years ago, I blogged about the use of the Raspberry Pi as an HDMI camera for the ATEM Mini. Although I have been using such a camera since then as my main Zoom camera, I wasn’t always happy with the image quality. The main problem was that the previous Raspberry Pi cameras had a fixed focus and it was quite hard to find the perfect focus.

Hidden Beauties of Java Enums

Let’s take a look at the power and beauty of what Java Enums can provide…

New Section Added to Foojay.io: Java Quick Start

Foojay.io aims to be the starting point for “all-things OpenJDK,” but during one of my morning walks the idea struck me that this site really needs complete beginner materials, too.

HiveMQ Cloud, part 4 - Sending sensor data from Raspberry Pi Pico W to HiveMQ Cloud

Exactly one year ago, in December 2021, I published three articles of MQTT messaging with Raspberry Pi, Raspberry Pi Pico and HiveMQ Cloud. On June 30th of 2022, Raspberry Pi released a new product, that is the subject of this post: the Pico W. Yes, a new version of the original Pico, but with Wi-Fi. The new board is for sale for 6$, compared to the 4$ of the original Pico.

Create Music Bingo cards with iText

It has been a while since I last had to create documents in a program, and iText has been “on my radar” to try out for a while now. This weekend we had a party and wanted to organize a music bingo. For this, we needed a set of randomly selected songs to be printed out per person. A small Java project seemed to be the best solution, otherwise, this would have been a boring, manual, and repetitive task. Isn’t that the goal of most of our developments? “Automate the boring stuff!”

Installing Java with SDKMAN on Raspberry Pi

If you create a new SD card for a Raspberry Pi with the operating system, you can choose the “Raspberry Pi OS Full (32-bit)” edition, which includes Java 11. But a lot of the other available OS-versions don’t have Java included.

Using a Raspberry Pi as HDMI camera

TL;DR; Yes, you can build your own Raspberry Pi HQ camera to use as an HDMI source for the ATEM Mini

Looking for an affordable camera with HDMI output? Build one yourself with a Raspberry Pi Zero 2!

HiveMQ Cloud, part 3 - Sending sensor data from Raspberry Pi Pico to HiveMQ Cloud

In the previous two posts in this series, we used Java on the Raspberry Pi mini-computer to send sensor data to HiveMQ Cloud, and visualize it on a dashboard.

HiveMQ Cloud, part 2 - Using MQTT and Raspberry Pi to Visualize Sensor Data on a TilesFX Dashboard

In the previous post we started our discovery of HiveMQ Cloud with Java on the Raspberry Pi. We created an application to send measurements of various sensors to the HiveMQ Cloud MQTT broker. Using an online websocket client we verified the transition of the messages, and could see the data being published to this online message queue.

HiveMQ Cloud, part 1 - MQTT on Raspberry Pi, Send Sensor Data to HiveMQ Cloud with Java and Pi4J

A few years ago I did my first experiments with an MQTT server (Mosquitto) running on a Raspberry Pi to connect an Arduino and Raspberry Pi for the drumbooth of my son. The full process is described in my book “Getting Started with Java on the Raspberry Pi”.

JavaFX running in kiosk mode on the Raspberry Pi

The Raspberry Pi in combination with an inexpensive touch screen, makes a perfect controller for a machine or game console. Let’s see how we can use Java and JavaFX to build a test application which also communicates with the pins of the Raspberry Pi to control a LED. We have done something before already in the post “Light Up your Christmas Tree with Java and Raspberry Pi”, so what’s new?

Device monitoring tool with JavaFX, FXGL and Mosquitto

In a previous post “Getting Started with FXGL Game Development” we already have taken a look at the FXGL game development framework developed by Almas Baimagambetov.

Starting a JavaFX Project with Gluon Tools

On foojay.io you can already find two posts by Carl Dea to get you started with JavaFX:

Courses

Java Quick Start

Is Java your first programming language and do you want to get up and running fast? Or maybe you are already an experienced programmer in another language and want to give Java a try?