[00:00.000 --> 00:10.760] Thanks for joining during your lunch. I have some pie for you, some raspberry pies with [00:10.760 --> 00:15.960] a little bit of Java coffee. So let's jump in. Normally there was a session planned now [00:15.960 --> 00:21.960] about Kotlin, so I have a little piece of Kotlin in this presentation. I'm not a Java [00:21.960 --> 00:28.040] Kotlin developer myself. What is the raspberry pie if you don't know it? This amazing small [00:28.040 --> 00:35.800] board. It's really small. This is the raspberry pie zero. And yes, indeed, that's 15 euros. [00:35.800 --> 00:41.440] This is a full PC, a full Linux PC, where you can run on Java, Java Vix. Anything that [00:41.440 --> 00:46.760] you do as a Java developer, you can also do on this small device. Of course, it's not [00:46.760 --> 00:51.520] so powerful, but it still allows you to do a lot of experiments. And what is special [00:51.520 --> 00:56.720] about raspberry pie is those pins where you can connect electronic components. And that's [00:56.720 --> 01:02.680] what I'm going to talk to you about. I see I have some missing images. That's a good [01:02.680 --> 01:08.920] start. There was also Raspberry Pi Pico announced, launched a few years ago. That's actually [01:08.920 --> 01:15.160] a micro control. So if you see a Raspberry Pi Pico, if you ever played with Arduino, [01:15.160 --> 01:20.760] it's more comparable to that, so we cannot run Java on that one. So what is a Raspberry [01:20.760 --> 01:25.320] Pie? It's a single board computer. You can run a lot of different Linux distributions [01:25.320 --> 01:30.120] on them. I mostly start with the Raspberry Pi operating system, which is the official [01:30.120 --> 01:36.880] one. But you also have gaming operating systems, NAS system, any kind of thing that you can [01:36.880 --> 01:43.920] think of does exist. There is a website, awesome Raspberry Pi where you will find all these. [01:43.920 --> 01:48.840] There are many versions, which are also 32 or 64 bits, which can be interesting if you [01:48.840 --> 01:55.680] want to do some specific experiments. And they make 400,000 Raspberry Pies a month. And [01:55.680 --> 02:02.120] still you cannot find them. Because of the ship shortage, this 400,000 is not enough. [02:02.120 --> 02:08.800] They do reserve a lot of them for industrial use. So as a consumer, a maker, you have to [02:08.800 --> 02:15.720] find them. RPILocator.com is a website which pulls a lot of websites who sell Raspberry [02:15.720 --> 02:20.920] Pies. And they list them. And if you follow them on Twitter or on Mastodon, you will get [02:20.920 --> 02:30.040] an alert if a certain type becomes available. I have been speaking at FOSDM virtually thanks [02:30.040 --> 02:37.520] to Fuji in the last two years. And in 2001, I spoke about how I got into Java on Raspberry [02:37.520 --> 02:42.280] Pi. I started doing some personal projects. I wanted to have a touchscreen control for [02:42.280 --> 02:48.080] the drum boot of my son. I wanted to use Java VIX. And I was missing a lot of documentation. [02:48.080 --> 02:54.080] So I wrote about that. And I ended up, even before building that thing for my son, I have [02:54.080 --> 03:00.440] written a book. And then afterwards, finally, he got his controller. It's in the book I [03:00.440 --> 03:04.160] explained and also in the FOSDM talk, how you get started with this, how you can use [03:04.160 --> 03:10.760] Pi for J. Pi for J is a library. More about that later to help you as a Java developer. [03:10.760 --> 03:21.840] And I also gave some examples of running Java VIX on a Raspberry Pi. So, 2001 was my explanation [03:21.840 --> 03:28.280] how I got started with Java on Raspberry Pi and has been my niche pet project ever since. [03:28.280 --> 03:33.560] And last year, I was here again because there were new Raspberry Pi boards launched. And [03:33.560 --> 03:39.680] we had to do some changes in Pi for J because they were not compatible anymore. And so, [03:39.680 --> 03:47.640] in 2021, we launched version 2 of Pi for J, which is more compatible with the newer [03:47.640 --> 03:53.400] boards, which uses Java 11 under the hood and allows you to do a lot of fun stuff. And [03:53.400 --> 04:00.360] I'll give you some examples. I also gave an example of a CropiOS. CropiOS is an operating [04:00.360 --> 04:06.680] system based on the official Raspberry Pi operating system. But FHNW is a university [04:06.680 --> 04:13.640] in Switzerland. They have a lot of courses where they use both Java, Raspberry Pi, electronics, [04:13.640 --> 04:18.960] all kinds of stuff. And they contribute a lot back to the Pi for J project. And they made [04:18.960 --> 04:23.600] an operating system with some additional tools for Java developers, like the latest Java [04:23.600 --> 04:29.760] VIX is there, the latest Java is there. On the background screen of your desktop, you [04:29.760 --> 04:33.560] see the IP number of your computer, which is very handy if you have a lot of Raspberry [04:33.560 --> 04:40.840] Pies and you never find back the connection to them. Also, some experiments with FXGL. [04:40.840 --> 04:47.520] Who has used FXGL or know what it is? No. Definitely take a look at it. It's by Almas. [04:47.520 --> 04:53.240] He's a professor at an English university and he created an amazing library for creating [04:53.240 --> 04:58.760] games. If you ever want to do some fun stuff and create a game with Java and Java VIX, [04:58.760 --> 05:05.360] FXGL is the project. And you will also find a lot of info about that on Fuji. And I also [05:05.360 --> 05:10.640] had some demos with HiveMQ. That's also something that is very easy to do, is messaging from [05:10.640 --> 05:17.000] Raspberry Pi towards a cloud provider. HiveMQ is a messaging platform, but they have a free [05:17.000 --> 05:22.800] cloud solution for up to 100 devices. Every maker with more than 100 devices can now raise [05:22.800 --> 05:30.720] his hands. Nope. That's the place to be where you can find those things. Now Py4j. Py4j is [05:30.720 --> 05:36.400] a Java library. That means it's a dependency. You add it to your Java project. Inside the [05:36.400 --> 05:44.200] library is native code. Native code that will call the different protocols that you can [05:44.200 --> 05:49.560] use to interact with the pins on your Raspberry Pi. So the simplest thing, you connect the [05:49.560 --> 05:55.760] LED and you can make the LED blink, but you can go a lot further, read temperatures, control [05:55.760 --> 06:05.200] led displays, all that kind of stuff. Now with the launch of Py4j version 2, we also [06:05.200 --> 06:09.760] launched a new website. And actually that's my role in the project. I didn't contribute [06:09.760 --> 06:16.120] a lot to the sources of the Py4j library, but I focused on the documentation part. Just [06:16.120 --> 06:21.280] like FooJ wants to be the source of truth for all Java developers to find information [06:21.280 --> 06:26.760] about Java, Py4j wants to be that for the Raspberry Pi, where you will have information [06:26.760 --> 06:32.640] about how you run Java Avix on a Raspberry Pi. One of the nice use cases of Java Avix [06:32.640 --> 06:39.840] is a kiosk mode so that a user interacting with your Raspberry Pi through a touch screen [06:39.840 --> 06:51.800] cannot do anything else than your application. They cannot go to reboot or in Linux terms. [06:51.800 --> 06:57.000] Now let's look back at what happened last year. For me personally, my biggest change [06:57.000 --> 07:04.040] is I joined Azure. Azure is one of the distributors of OpenJDK. I'm part of the documentation [07:04.040 --> 07:10.680] team. And because of that, I can also focus a bit on writing documentation for FooJ articles [07:10.680 --> 07:17.600] and other stuff like that. But it was meant to be because Azure has a lot of distributions [07:17.600 --> 07:27.680] of, it's called Zulu. That's the core product of Azure is a distribution of OpenJDK, like [07:27.680 --> 07:33.400] you have so many. What is the main advantage of Azure Zulu is that it is available for [07:33.400 --> 07:47.680] a lot of platforms, more platforms and most other distributors. That's the nice thing [07:47.680 --> 07:52.840] that I found out after joining Azure. They are even the only one which supports all the [07:52.840 --> 08:02.640] oldest Raspberry Pi models. Now what I also found out is who knows SDKaman? Yes? Okay, [08:02.640 --> 08:08.200] look it up. SDKaman allows you to switch between Java versions with one command. It didn't [08:08.200 --> 08:15.880] run on the Raspberry Pi. And that was of course that hurt. So FooJ, the website for Friends [08:15.880 --> 08:22.760] of OpenJDK, behind the scenes there is the Disco API. The Disco API is an API to search [08:22.760 --> 08:30.160] for Java distributions. Now the same Disco API is used by SDKaman. And SDKaman is a tool [08:30.160 --> 08:36.280] for Linux and Mac where you can do, it's a one line installation script, then you do [08:36.280 --> 08:42.440] SDKalist Java and you will get a list of all the available Java distributions for your [08:42.440 --> 08:49.800] platform. Now because of the Disco API and small changes done by Gerrit Grunwald, who [08:49.800 --> 08:55.080] is also an Azure colleague who is maintaining that, and by changes in SDKaman and I did [08:55.080 --> 09:01.720] a very few, very small commits to that, we were able to get to this. So if you have this [09:01.720 --> 09:07.560] Raspberry Pi zero from the first generation which has an ARMv6 processor, is a different [09:07.560 --> 09:13.480] architecture than the newer ones, you will get four versions of Java that you can install. [09:13.480 --> 09:24.320] Unfortunately, it's only Zulu. As I say, it's only Zulu who will work. There is still a [09:24.320 --> 09:29.920] problem with the architecture of the processor that has some issues there. But so you can [09:29.920 --> 09:38.880] install with SDKaman Java on any type of Raspberry Pi because, yep, I have something else here. [09:38.880 --> 09:46.080] If you run the same command on a newer Raspberry Pi with a 64-bit operating system, Raspberry [09:46.080 --> 09:54.720] Pi always has that now, since recently, officially, 45 extra lines. So there are more than 50 [09:54.720 --> 10:00.200] Java distributions and this screenshot, I think it dates from, it's from a Fuji article [10:00.200 --> 10:08.680] in last February. So Java 19 is not on this list. So there are now more than 60, I guess, [10:08.680 --> 10:15.840] Java versions that you can install, distributions that you can install on a Raspberry Pi. [10:15.840 --> 10:24.720] Another article I wrote for Fuji is G-Bang. Who used G-Bang? No. Since Java 11, I think [10:24.720 --> 10:29.680] you can run Java files without compiling them. If you have a single Java file which does [10:29.680 --> 10:39.320] some simple things, you can just run it. You don't need to compile it. What G-Bang adds [10:39.320 --> 10:46.000] is you can define your dependencies in that one single file. So if you install G-Bang on [10:46.000 --> 10:51.560] Raspberry Pi or on any computer where you didn't run Java yet, it will install Java [10:51.560 --> 10:59.640] for you. And then you can just create a text file. And then with this Gradle-style definition [10:59.640 --> 11:07.920] of dependencies inside your Java file, G-Bang has everything it needs to run your code. [11:07.920 --> 11:13.600] So this example is based on the minimal code example that we have on the Pi 4j website. [11:13.600 --> 11:24.040] It's just to control a lit. Let me see if the video works here. If it doesn't show you, [11:24.040 --> 11:32.600] I will just forward you to fuji.io where you can find the full, nope, no video. Okay. We [11:32.600 --> 11:39.720] didn't try this before. You see the sessions here go very fast there. How much time there? [11:39.720 --> 11:46.160] Another fun project I love is Vaadin. Vaadin allows you to build user interfaces with [11:46.160 --> 11:52.280] pure Java. So if you have played with Java VIX, it's a bit the same feeling but then [11:52.280 --> 12:01.320] for web applications. Vaadin, so you have button elements and table views and all that [12:01.320 --> 12:07.080] kind of stuff. I also wanted to create an example using Vaadin on the Raspberry Pi and [12:07.080 --> 12:13.320] that's exactly what I have done and this video will play. So this is the web interface without [12:13.320 --> 12:19.480] any modification that you get from a default Vaadin project. There you have a custom setup [12:19.480 --> 12:25.800] with just a let and a small button and then you have Vaadin application running. So this [12:25.800 --> 12:32.840] is a spring application, combination of spring, Vaadin, Pi 4J and that's running on the Raspberry [12:32.840 --> 12:38.000] Pi. So it's running on the Raspberry Pi you see also on the top. I'm not going to show [12:38.000 --> 12:42.520] you any rocket science experiments. It's just pure basics. It's blinking a lot. The [12:42.520 --> 12:49.240] hello world of programming electronics and you see after the button has been touched [12:49.240 --> 12:58.000] that the info changes there. So that's all what is documented. Five minutes, okay. Good. [12:58.000 --> 13:04.440] I promised you some Kotlin. I'm not a Kotlin developer myself but Pi 4J, the project, it's [13:04.440 --> 13:09.440] a community project. It's an open source project so we welcome anyone who wants to contribute [13:09.440 --> 13:16.400] and Mohammed Hashim who once as a student I think developed a Kotlin implementation [13:16.400 --> 13:22.440] of the first version of Pi 4J said I can do that again. So he created a Kotlin implementation [13:22.440 --> 13:27.960] on top of Pi 4J. So if you are a Kotlin developer and want to do Kotlin on the Raspberry Pi, [13:27.960 --> 13:34.240] you can do so and even control electronics. I'm not a Kotlin developer. These are just [13:34.240 --> 13:39.640] some example codes that I took from his examples. Now what the fun thing is that he also went [13:39.640 --> 13:45.000] back to the documentation part of the Pi 4J website and added four pages or five pages [13:45.000 --> 13:49.160] with documentation about how to do this with Kotlin. So if you are interested in Kotlin [13:49.160 --> 13:58.280] on the Raspberry Pi, go to Pi4J.com. Now a few things I can tell you about this year [13:58.280 --> 14:04.720] and what we're going to do. Just as an experiment again, I wanted to create a library. Now I [14:04.720 --> 14:10.840] got very worried about how I have to maintain libraries and the legal parts so I don't know [14:10.840 --> 14:16.200] if this was a good idea. I wanted to create a library containing a database of all the [14:16.200 --> 14:21.840] Raspberry Pi's, the history and what pins they have and what you can do with these pins. [14:21.840 --> 14:25.920] We need it for another project so I wanted to create this library. Now on top of this [14:25.920 --> 14:34.440] library we actually created API.Pi4J.com. And again I used Waden. I know it. I've used [14:34.440 --> 14:42.240] it before. So this application, API.Pi4J.com, it's public. It's using a library containing [14:42.240 --> 14:47.280] a database with Raspberry Pi information and it's visualizing it here and because it's [14:47.280 --> 14:52.480] a spring application we can of course have Swagger and all that kind of stuff. But the [14:52.480 --> 14:58.000] fun thing is of course it runs on the Raspberry Pi. It runs on the Raspberry Pi that we got [14:58.000 --> 15:04.840] from this company FinalTech.com in Czech so somewhere in Prague in the data center Raspberry [15:04.840 --> 15:10.480] Pi is hosting this Pi4J.com. I don't know how performant this is so if you all visited [15:10.480 --> 15:18.080] at the same time we will know it. And then something unexpected happened a few weeks [15:18.080 --> 15:27.480] ago. I was asked by Daniel Frey how about Spring Boot and Pi4J. Does that exist? No. [15:27.480 --> 15:33.120] But now it does because he created it. So Daniel Frey and the Sean Carter are two guys [15:33.120 --> 15:40.960] from the Spring team and they just developed this. And I joined them in a Twitch. It was [15:40.960 --> 15:46.640] a bit chaotic but yeah it was a Twitch. And we didn't finish it yet but we're working [15:46.640 --> 15:54.800] on it. So you'll have a Spring Boot starter that will help you to detect which Raspberry [15:54.800 --> 15:59.760] Pi you are running it on, how it should be configured. It will create a context for you. [15:59.760 --> 16:05.400] The context is that it loads all the plugins to control the GPIOs. And that you will be [16:05.400 --> 16:14.400] able to also, how is it called? The info controller, the Prometheus list of all the data that you [16:14.400 --> 16:20.120] get from Spring and what? That you can use it for Grafana. So you will have all this [16:20.120 --> 16:27.040] data available. What IO pin is toggled? What is active? What is the signal that is arriving [16:27.040 --> 16:31.720] at this pin? So that kind of info, it's not finished. We're working on it so maybe if [16:31.720 --> 16:39.680] I'm back here next year, I can show you. So what is next? You can visit me on Twitter. [16:39.680 --> 16:44.920] I'm also on Mastodon on the Fuji's social account. Of course with Fuji we also started [16:44.920 --> 16:50.440] the Mastodon service. And I write a lot about all this kind of stuff and you can find it [16:50.440 --> 17:18.080] either on Fuji or by Fuji. And that's all I want to do. Thank you.