Thanks for joining during your lunch. I have some pie for you, some raspberry pies with
a little bit of Java coffee. So let's jump in. Normally there was a session planned now
about Kotlin, so I have a little piece of Kotlin in this presentation. I'm not a Java
Kotlin developer myself. What is the raspberry pie if you don't know it? This amazing small
board. It's really small. This is the raspberry pie zero. And yes, indeed, that's 15 euros.
This is a full PC, a full Linux PC, where you can run on Java, Java Vix. Anything that
you do as a Java developer, you can also do on this small device. Of course, it's not
so powerful, but it still allows you to do a lot of experiments. And what is special
about raspberry pie is those pins where you can connect electronic components. And that's
what I'm going to talk to you about. I see I have some missing images. That's a good
start. There was also Raspberry Pi Pico announced, launched a few years ago. That's actually
a micro control. So if you see a Raspberry Pi Pico, if you ever played with Arduino,
it's more comparable to that, so we cannot run Java on that one. So what is a Raspberry
Pie? It's a single board computer. You can run a lot of different Linux distributions
on them. I mostly start with the Raspberry Pi operating system, which is the official
one. But you also have gaming operating systems, NAS system, any kind of thing that you can
think of does exist. There is a website, awesome Raspberry Pi where you will find all these.
There are many versions, which are also 32 or 64 bits, which can be interesting if you
want to do some specific experiments. And they make 400,000 Raspberry Pies a month. And
still you cannot find them. Because of the ship shortage, this 400,000 is not enough.
They do reserve a lot of them for industrial use. So as a consumer, a maker, you have to
find them. RPILocator.com is a website which pulls a lot of websites who sell Raspberry
Pies. And they list them. And if you follow them on Twitter or on Mastodon, you will get
an alert if a certain type becomes available. I have been speaking at FOSDM virtually thanks
to Fuji in the last two years. And in 2001, I spoke about how I got into Java on Raspberry
Pi. I started doing some personal projects. I wanted to have a touchscreen control for
the drum boot of my son. I wanted to use Java VIX. And I was missing a lot of documentation.
So I wrote about that. And I ended up, even before building that thing for my son, I have
written a book. And then afterwards, finally, he got his controller. It's in the book I
explained and also in the FOSDM talk, how you get started with this, how you can use
Pi for J. Pi for J is a library. More about that later to help you as a Java developer.
And I also gave some examples of running Java VIX on a Raspberry Pi. So, 2001 was my explanation
how I got started with Java on Raspberry Pi and has been my niche pet project ever since.
And last year, I was here again because there were new Raspberry Pi boards launched. And
we had to do some changes in Pi for J because they were not compatible anymore. And so,
in 2021, we launched version 2 of Pi for J, which is more compatible with the newer
boards, which uses Java 11 under the hood and allows you to do a lot of fun stuff. And
I'll give you some examples. I also gave an example of a CropiOS. CropiOS is an operating
system based on the official Raspberry Pi operating system. But FHNW is a university
in Switzerland. They have a lot of courses where they use both Java, Raspberry Pi, electronics,
all kinds of stuff. And they contribute a lot back to the Pi for J project. And they made
an operating system with some additional tools for Java developers, like the latest Java
VIX is there, the latest Java is there. On the background screen of your desktop, you
see the IP number of your computer, which is very handy if you have a lot of Raspberry
Pies and you never find back the connection to them. Also, some experiments with FXGL.
Who has used FXGL or know what it is? No. Definitely take a look at it. It's by Almas.
He's a professor at an English university and he created an amazing library for creating
games. If you ever want to do some fun stuff and create a game with Java and Java VIX,
FXGL is the project. And you will also find a lot of info about that on Fuji. And I also
had some demos with HiveMQ. That's also something that is very easy to do, is messaging from
Raspberry Pi towards a cloud provider. HiveMQ is a messaging platform, but they have a free
cloud solution for up to 100 devices. Every maker with more than 100 devices can now raise
his hands. Nope. That's the place to be where you can find those things. Now Py4j. Py4j is
a Java library. That means it's a dependency. You add it to your Java project. Inside the
library is native code. Native code that will call the different protocols that you can
use to interact with the pins on your Raspberry Pi. So the simplest thing, you connect the
LED and you can make the LED blink, but you can go a lot further, read temperatures, control
led displays, all that kind of stuff. Now with the launch of Py4j version 2, we also
launched a new website. And actually that's my role in the project. I didn't contribute
a lot to the sources of the Py4j library, but I focused on the documentation part. Just
like FooJ wants to be the source of truth for all Java developers to find information
about Java, Py4j wants to be that for the Raspberry Pi, where you will have information
about how you run Java Avix on a Raspberry Pi. One of the nice use cases of Java Avix
is a kiosk mode so that a user interacting with your Raspberry Pi through a touch screen
cannot do anything else than your application. They cannot go to reboot or in Linux terms.
Now let's look back at what happened last year. For me personally, my biggest change
is I joined Azure. Azure is one of the distributors of OpenJDK. I'm part of the documentation
team. And because of that, I can also focus a bit on writing documentation for FooJ articles
and other stuff like that. But it was meant to be because Azure has a lot of distributions
of, it's called Zulu. That's the core product of Azure is a distribution of OpenJDK, like
you have so many. What is the main advantage of Azure Zulu is that it is available for
a lot of platforms, more platforms and most other distributors. That's the nice thing
that I found out after joining Azure. They are even the only one which supports all the
oldest Raspberry Pi models. Now what I also found out is who knows SDKaman? Yes? Okay,
look it up. SDKaman allows you to switch between Java versions with one command. It didn't
run on the Raspberry Pi. And that was of course that hurt. So FooJ, the website for Friends
of OpenJDK, behind the scenes there is the Disco API. The Disco API is an API to search
for Java distributions. Now the same Disco API is used by SDKaman. And SDKaman is a tool
for Linux and Mac where you can do, it's a one line installation script, then you do
SDKalist Java and you will get a list of all the available Java distributions for your
platform. Now because of the Disco API and small changes done by Gerrit Grunwald, who
is also an Azure colleague who is maintaining that, and by changes in SDKaman and I did
a very few, very small commits to that, we were able to get to this. So if you have this
Raspberry Pi zero from the first generation which has an ARMv6 processor, is a different
architecture than the newer ones, you will get four versions of Java that you can install.
Unfortunately, it's only Zulu. As I say, it's only Zulu who will work. There is still a
problem with the architecture of the processor that has some issues there. But so you can
install with SDKaman Java on any type of Raspberry Pi because, yep, I have something else here.
If you run the same command on a newer Raspberry Pi with a 64-bit operating system, Raspberry
Pi always has that now, since recently, officially, 45 extra lines. So there are more than 50
Java distributions and this screenshot, I think it dates from, it's from a Fuji article
in last February. So Java 19 is not on this list. So there are now more than 60, I guess,
Java versions that you can install, distributions that you can install on a Raspberry Pi.
Another article I wrote for Fuji is G-Bang. Who used G-Bang? No. Since Java 11, I think
you can run Java files without compiling them. If you have a single Java file which does
some simple things, you can just run it. You don't need to compile it. What G-Bang adds
is you can define your dependencies in that one single file. So if you install G-Bang on
Raspberry Pi or on any computer where you didn't run Java yet, it will install Java
for you. And then you can just create a text file. And then with this Gradle-style definition
of dependencies inside your Java file, G-Bang has everything it needs to run your code.
So this example is based on the minimal code example that we have on the Pi 4j website.
It's just to control a lit. Let me see if the video works here. If it doesn't show you,
I will just forward you to fuji.io where you can find the full, nope, no video. Okay. We
didn't try this before. You see the sessions here go very fast there. How much time there?
Another fun project I love is Vaadin. Vaadin allows you to build user interfaces with
pure Java. So if you have played with Java VIX, it's a bit the same feeling but then
for web applications. Vaadin, so you have button elements and table views and all that
kind of stuff. I also wanted to create an example using Vaadin on the Raspberry Pi and
that's exactly what I have done and this video will play. So this is the web interface without
any modification that you get from a default Vaadin project. There you have a custom setup
with just a let and a small button and then you have Vaadin application running. So this
is a spring application, combination of spring, Vaadin, Pi 4J and that's running on the Raspberry
Pi. So it's running on the Raspberry Pi you see also on the top. I'm not going to show
you any rocket science experiments. It's just pure basics. It's blinking a lot. The
hello world of programming electronics and you see after the button has been touched
that the info changes there. So that's all what is documented. Five minutes, okay. Good.
I promised you some Kotlin. I'm not a Kotlin developer myself but Pi 4J, the project, it's
a community project. It's an open source project so we welcome anyone who wants to contribute
and Mohammed Hashim who once as a student I think developed a Kotlin implementation
of the first version of Pi 4J said I can do that again. So he created a Kotlin implementation
on top of Pi 4J. So if you are a Kotlin developer and want to do Kotlin on the Raspberry Pi,
you can do so and even control electronics. I'm not a Kotlin developer. These are just
some example codes that I took from his examples. Now what the fun thing is that he also went
back to the documentation part of the Pi 4J website and added four pages or five pages
with documentation about how to do this with Kotlin. So if you are interested in Kotlin
on the Raspberry Pi, go to Pi4J.com. Now a few things I can tell you about this year
and what we're going to do. Just as an experiment again, I wanted to create a library. Now I
got very worried about how I have to maintain libraries and the legal parts so I don't know
if this was a good idea. I wanted to create a library containing a database of all the
Raspberry Pi's, the history and what pins they have and what you can do with these pins.
We need it for another project so I wanted to create this library. Now on top of this
library we actually created API.Pi4J.com. And again I used Waden. I know it. I've used
it before. So this application, API.Pi4J.com, it's public. It's using a library containing
a database with Raspberry Pi information and it's visualizing it here and because it's
a spring application we can of course have Swagger and all that kind of stuff. But the
fun thing is of course it runs on the Raspberry Pi. It runs on the Raspberry Pi that we got
from this company FinalTech.com in Czech so somewhere in Prague in the data center Raspberry
Pi is hosting this Pi4J.com. I don't know how performant this is so if you all visited
at the same time we will know it. And then something unexpected happened a few weeks
ago. I was asked by Daniel Frey how about Spring Boot and Pi4J. Does that exist? No.
But now it does because he created it. So Daniel Frey and the Sean Carter are two guys
from the Spring team and they just developed this. And I joined them in a Twitch. It was
a bit chaotic but yeah it was a Twitch. And we didn't finish it yet but we're working
on it. So you'll have a Spring Boot starter that will help you to detect which Raspberry
Pi you are running it on, how it should be configured. It will create a context for you.
The context is that it loads all the plugins to control the GPIOs. And that you will be
able to also, how is it called? The info controller, the Prometheus list of all the data that you
get from Spring and what? That you can use it for Grafana. So you will have all this
data available. What IO pin is toggled? What is active? What is the signal that is arriving
at this pin? So that kind of info, it's not finished. We're working on it so maybe if
I'm back here next year, I can show you. So what is next? You can visit me on Twitter.
I'm also on Mastodon on the Fuji's social account. Of course with Fuji we also started
the Mastodon service. And I write a lot about all this kind of stuff and you can find it
either on Fuji or by Fuji. And that's all I want to do. Thank you.