 Hello, Java developers. My name is Matt Raebel. And today I'd like to show you how to build a secure rest API, and native image using Heladon. Let's get it up. I created a demo script for this, you can find it in octadev native Java examples, and the demo dash heladon dot adoc file. And like I said, we're going to create a Java REST API, secure it with OAuth2, and then we'll pass a JWT to it to authenticate our user. And then I'll do some comparisons with other frameworks that allow you to build Java REST APIs like Micronaut, Quarkus, and Spring Boot. And so for the demo script, for the repo, for a related blog post, check out the description on this video, I put links all over in there, and you'll be able to find all this information. The first thing you'll need is SDK man, I already have it installed. And if you need to get it, you can get it from SDK man dot IO, and then HTTP IE. And you can get that from HTTP by e.org, I believe. And then CLI dot octa.com is where you get the octa CLI, I already have that installed as well. At the end of some of the steps, you'll find IntelliJ live templates that I use. So they're just little brackets, and I store those in idea live templates on GitHub. So if you want to import them and use them, you certainly could but there's just a couple and you could copy and paste the code just as easily. So with SDK man, you can install Java 17. I already have installed. And so if I did Java version, you would see it there. If you want to see all the Java or all VM versions available, you can SDK list Java, and then grep for girl there. And then the first thing I want to do is generate an OAuth 2 access token. So with the octa CLI that makes it pretty easy. If you don't have an octa account, you can do octa register, or octa login if you do. And then I'll do octa apps create spot. And this we're going to use OIDC debugger for this. That's a website that allows you to easily create an access token. And the post logout redirect UI should match there. And then you'll see we got that client ID and issuer. So if we were to go to the site, it does remember my information from last time. So you might have to add, you know, your issuer here, and then tack on v1 authorize, and then copy in your client ID. And, you know, everything else is okay, the defaults with code, you might need to check pkce because I don't believe that's a default. And then make sure and tack on v1 token there. And then click send request. And it comes back and does the pixie dance, and gets me that access token. So now I can set that right here. And back to our instructions. And we'll build a Java REST API with held on. So using their Maven archetype. We'll see the into downloads here, and run it. And this is using the hell it on quick start micro profile there. And then we can open that up in IntelliJ. There's also a held on CLI you can use, and run held on a knit for that. The first thing you'll need to do is add micro profile JWT support in the palm dot XML so just right at the top there should be fine. And then add a low resource. Looks like I got a type of there. And the source main Java here. And we'll put it in the controller package. And then we got a shortcut. Tell J live template. And this, you know, is just at the available at the path of slash hello. And it does a get request. I don't believe we actually need that one in there. That one should work fine. And then, you know, returns the user's information from the principle. So then we can also add a hello application to register that class. And this is that each app for my shortcut. No. Alright, we'll just copy and paste it then. And re import to get that JWT import. And then you can see we just register the class there, application scoped, it's just part of micro profile. And then we'll add our octa endpoints into source main resources meta and micro profile config dot properties. So this is our octa domain, which we have back here, replace that. There is no command to just start up a heledon app if you use heledon CLI there is. But I've just been doing MVM package and Java dash jar with the generated, you know, jar there. And what do we have here, we have a test failure. Uh oh, we better go. Oh, we need to delete these two because well, we don't need them. And then I think it generates a test as well. So that main test looks like it goes to greet Joe. And yeah, we'll just delete it. Who needs tests anyway, right? And then we'll go ahead and run it again. And then it doesn't like that we forgot to put jar on there, which makes perfect sense. I don't blame it. So it starts up. And now we can go ahead and hit that endpoint with our token. Make sure and reset it there. invalid URL. Let's see. Maybe I just did the command wrong. Yep, looks like it. I did it in the wrong order. So I got some cleanup to do on my instructions. If you go to the demo script after this, I make I'll make sure it's all up to date. But you can see, you know, it's logging in, it's got my information there. And it's all working. So let's go ahead and build a native heledon app. So I want to make sure it's not running in the background. And then make sure you're in the project. You can see that took just over a minute to run there a minute 20 seconds, according to my calculations. And now we can go ahead and start it up with target heledon. You'll see it's kind of buried in here, but it gives the time it started there 54 milliseconds. So let's try it again. 31 milliseconds. And 31. So that seems to be pretty consistent there. That's all working nicely. If we did a startup time comparison here with the other frameworks, what I did was I cloned them all or I created apps just like I showed you how to do here. And then I started them all three times. And then I started them five times and took the average of that. So you can see, you know, milliseconds to start here for heledon is 42. This is on an M1. So it's much faster here with 30 milliseconds. This was on Intel that I originally recorded these numbers. So with Micronaut, it's 27 milliseconds. With Quarkus, wicked fast 19 milliseconds. And then Spring Boot, a little bit slower than heledon there. And then the memory usage. This is a command I used to figure out memory usage with heledon. It starts up before any request 42 megs used, which is awesome for a job application, right? And after five requests, it has 62. And then you can see the comparison with the others there. And then what about the MacBook Pro M1, which I'm using to record this? You know, the milliseconds to start is 23. So faster than when I'm recording this with Camtasia. And, you know, the megabytes go up a bit after the request. Not sure why that is. But my basic synopsis is it builds twice as fast, which is very nice for a developer experience. It starts twice as fast, which is again very nice. But it does use a bit more memory. And so what we did with the Octa CLI is we made it easy to create a heledon app that integrates with Octa. So if I were to, you know, exit out of here and cancel this one and go up a level and create a new directory, clear this so you can see it easier. Octa start heledon. It'll actually go out to GitHub repo that we maintain and create a new OIDC application for you and tell you, you know, everything's been written to this file. So, you know, use get ignore to check that in or to ignore that file with if it has client secrets in it, which it doesn't right now, or use environment variables. And you can find this example's code in that native Java examples repo and the heledon directory. And of course, the blog post, build rest APIs and native Java apps with heledon. So I hope you've enjoyed this screencast. If you want to find me, I'm on Twitter at mrable. You can find my team at octadev and subscribe to our YouTube channel so you can get notifications when we publish more cool content like this. Thanks for watching. Have a great day.