Getting started with Java in VS Code

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] [Music] um [Music] hello welcome to devradio we're here for the first part of our azure java jump start series we'll be three-part series with rory pretty and uh today we're getting started with java in vs code and rory i'll go ahead and just hand things over to you and uh show us what we need to learn today thanks matt and and it's a it's a very demo heavy session that we're going to do today i'm going to show you how to uh install the coding pack and then i'm going to show you some of the the masking features of uh java on visual studio code and then we're going to clone a sample application and push it to azure and then the next sessions that we're going to do there we're going to say take the same app and we're going to uh look at some of the features that azure has and how to even use azure screen cloud in the last session and so you should see my screen in front of you right now um and you see there that i've uh opened up the uh the install coding pack for java so it's a nice little bundle that you get uh with uh the team from visual studio code and we've got all the links uh a little bit later in the session and we'll pop them on to our uh our links and you can get all of this there now with the install coding pack for job it comes with all of the extensions you need and also a java development kit so it's out of the box now the only difference is on my macintosh here i've also installed the microsoft open jdk which is a great way uh to a kind of leverage of the the microsoft java teams and knowledge of azure and java and you can actually get get that for free with the open jdk license so i've got the install uh coding pack for java and the next thing it's going to do is going to scan my pc my mac and say what do you have there and you can see the output up to java 16 so it says that's great you need at least java 11. um you can use java 8 but you need java 11 to run visual studio code so i've got java 16 that's great and then i've got visual studio code already installed so if i click on install here it's not really going to match too much it's just going to say i try to do some in stores and everything worked out fine and now i'm going to launch visual studio code and when i launch visual studio code if i had a project beforehand and it's going to open up visual studio code else it's going to open up a uh a new project wizard so let's go finish here and then it's going to you can see the little there and it's going to open up a a blank project wizard here let me let me make that bigger and also uh zoom in here and it's got really uh no real screens there so we're going to click on um over there which is the explore review um and one of the the nice things that i like here you can actually go into uh view command prompt and you can go screencast uh toggle screen class mode on visual studio here uh toggle screencast mode and the moment you do that you can click there and makes great for great presentation a lot of people don't realize that and if i type you can see here hhh it actually tells you so during the session we can actually see that so if you go into your explorer view you'll see there that you can open a folder for an existing project you can clone a repository you can open up a github repository now with the java pack you can actually go in and create a java pack uh project so if i go create a java project you can do all of these things from maven spring booth quarkus micro profile and you can have all of these starters there that you you can run but we're not gonna do that we're gonna we're going to clone a project and i'm going to clone a very popular project called the uh this the spring pet clinic so i'm going to uh let's go here and we're going to go clone repository and then i'm going to just clone there you can see there i've forked the spring picnic and the rory key spring pit clinic dot get um and then i can just go in and hit enter i'm just going to say where do you want to do that and let's create a new folder here and we're going to call that uh the map folder uh matt you you're on my pc here on uh on my mac um selector select the repository location it's going to clone it here and then it's going to open up the project and you can see yeah do you want to open the clone repository act and go okay and the minute you do that you'll see that it's got the project there but it's also going to say wow this is a java project and you can see at the bottom there it's going to say opening java project you can go check details and it's going to say importing the maven project which is the maven repository which is the uh kind of the packet manager for java and it's going to go in and download all of that because it knows it's a maven project it's already scanned it in and then it's going to go and process them process it accordingly projects are imported you can go view the projects and you can see there i immediately see a java project's view and you eclipse developers out there will recognize this it's very similar to some of the classic ides that java developers use and you'll get the nice view so this is the file view of the exploded file view and this is the java project view where you'll get the source main and everything kind of exploded into packages you also see that i've got the java system libraries uh exploded there and it's importing the 1.8 project java 1.8 even though that i'm using java 11 microsoft version of java 11 it knows and it's clever enough to go wait a second i know that i need to use the java 1.8 uh libraries i've also got my maven dependencies and loaded those in uh automatically uh for me so um if i go into my java project files so source main java and are going to the spring pet clinic application there you'll see that as i click on a java snippet it's going to uh check and build there and then it's going to tell me what version of java i'm running this you can see there i'm using the language level of java 1.8 and then it's got all of my um the full url url path of the java jdk that i'm using you can change that if you want you can go into view uh command palette and link and toggle the screen cost mode again so you can go uh view command palette and you can go configure java runtime and if you go configure java runtime uh let's just minimize that there for a second you can see there that i've got uh at some new screens here i've got workspace overview uh it's using 1.8 there the actual project what if the jdk is using is microsoft dash 11 jdk on my mac you can also go in there and choose the language server now the language server is an off process json uh server that actually does all of your passing now that needs to run java 11 but you can run java 18 and some of your other projects there a little bit of confusing but i like to think run java 11 and you don't have to worry about anything really in the microsoft jdk really the open jdk runs java 11. you can also install other jdks you can see there i've got java 16 15 11 8 i don't have to worry about them because visual studio runs it for me and you can install a jdk and it will pick it up automatically for you and what is that the microsoft build of open jdk new there and that's great news because we've got such an incredible team that is managing this and you can go install it there and then we'll be picked up automatically uh with that so now this project is running that and i want to show you some of the features that you actually now can use with that um so yeah so let's uh let's close that for a second there and and you'll see that this is a a java project and the last thing about the java project if you are a github code pilot user you'll know that github copilot actually works with uh you can see there um spring spring clinic spring application so github co-pilot and also code sense users uh the uh the the intellisense there and you can see there that i can get all of those intellisense around all of the developers that i have so that's the first feature that i want to show you that you have there you can see that's a github code pilot and knows exactly what i want to do there and i can just go tab and get there so this it is running under private uh public uh private preview so you can actually sign it up with that and if i do go uh into another class so let's go into the vet class and i'll come back to how this project works uh let's move into that vet controller just want to show you here so if i go at vets dot you'll see there that i've got all of the the possible options that i can actually choose i can also if i go into a little bit uh more detail i can go uh like model model dot put you'd see they have a little star there and that's what most developers actually will use in intellisense for java so if you're worried about what to do you can use github code column if you don't have git code you can also see what are most developers using with java and telesense so very similar to net you get that intellisense and that view for exactly what you're doing with your project so let's go through the project that we have here so in our picnic application it's used to take uh pets to uh veterinarians for visits so you've got your uh owner you've got your vet and you've got your visits objects and and in your uh packages in your vet you've got your models or your vet model here and that vet model here that extends a person a person class and you've got the entities and i'm not going to bore you too much uh matter around that but this is the classic kind of spring and jpas or java persistence architecture that you have here so what is this person here and how do i actually manage it so i want to see here for the top hierarchy one of the new features that we get here if you if you click on person here or vet you can right click in here and you can go show top hierarchy and this is a new feature actually uh let's let's hope that that works a little bit yeah let's go here let's go refresh and there we go yay a lot of demos now i've got that entire hierarchy there i've got that person-based entity in object and i can go into personal object here and i can say wait a second let's go uh show or go to references implementations superimpo implementations so that your classic kind of ide features so uh let's go find all implementation for person and then i can see here that owner and vet actually do that and this is a this is actually a new feature in digital studio code for java so you get this uh top hierarchy and the ability to actually drill down and see exactly what are all of the objects the super and the subclasses for the implementations for each of that so that's top hierarchy so what about if i wanted to move a class and and how do i do that because a lot of teams uh are relying on uh rdes to be able to do that so in my uh vet i've got a speciality the job so your vet might be a special vet mud working cats and dogs and i want to move the specialty that drive classic into the owner class i can drag it into owner here and it's going to say do you want to move and i'll go yes i do want to move and it's going to scan in all of the dependencies and go do you want to show a preview so i'm going to go yes show preview and then it's going to say wow these are all the changes i'm going to make for you my package costs there the named entity and then i can actually go in and let's make it a little bit smaller there and then i can just go in there and go click i like that and it's made the changes for me and that's a great like team collaboration system that you want to use uh with that so um and then i can go into my source control because this is reaper uh clone from a repo and i can see there that everything's changed and also moved back now the asset test is i'm going to move it back and there shouldn't be any changes because then we know that it's kind of doing what i wanted to so i've moved unfailed once back into vet uh move it back there and uh show preview i like what i see there okay and now if i go back into changes and i hit refresh yeah no changes live demo yay and now i've got everything working there so that's a lot of refactoring so i've shown you the top hierarchy and refactoring and then once i'm happy with that now i can go in and build my project and there's another view that you have here and this also is new of your maven hierarchy so maybe it's like nougat or npm and you can go into your maven view here um a little bit bigger you can go to your last cycle here and i'm going to just go into the install here and the install is going to run all my tests and also execute my build life cycles it's going to create my under my target folder there it's going to create my jar file my java archive file and and then it's going to run through the entire build process you can see that i've also got some css files it's going to actually do that post processing there it's going to run through my test then um and all of this is actually contained inside the ibe so it's not running off process there which is great the only thing that's running off process is the intellisense monitoring so this will come through and hopefully all of this will run fun and it's going to run all the tests yeah it's successful now now that i've got my target folder here and you can see there i've got my jar file a spring pet clinic jar file now how do i run that one is i can run that from command line or what i can actually do is that i can run that for my unit tests so next thing i want to show you here is that we've got some new features here under testing so i've got one of these tests uh here and i can go through each one of these so the owner controller tests here i can go test process controller and let's go run through that and let's go right click and go go to test and you've got the test projects here that all already run and it's got an mvc a mock mvc and what happens if i want to generate the test a new feature that we've had there you can go source action and you can go uh generate tests you can go organize import generate getters and setters all of your plastic ide functions so we can go generate tests and you can get all of those tests before test after around that but i can actually go into my test here and i can just go uh let's just run that test pro uh test process creation form success for uh my uh my owner and you can see that it runs there fine and with maven actually runs all those tests for me automatically and then feeds back into my test view so you can create the test and you can run the tests so let's run it we did run it there with marking but let's run it locally and there's another view that i want to show you here for a spring boot dashboard now this is usually a paid for feature in a lot of ides you can see there i've got screenplay clink here and i'm going to run this and i'm going to switch on debugging function so i'm going to go in there and under the uh owner controller let's go find the owner controller i'm going to debug a function there and i want it to break on uh ownercontroller.find.org uh so let's go into uh uh owner controller and when i found all the owners i wanted to break and then we'll get our first view uh on uh on so i'm gonna create a breakpoint here you can create a conditional breakpoint here and it's gonna say if owner.getlastname is not null and then uh i set the last name as as that so let's go into our spring boot dashboard and let's hit uh debug function so hit debug function here and now it's going to start up the debugger for java and it's going to bring up what's not going to bring up the browser but i can go and click it there if i go right into the bottom i can click there and go into the uh large phone window and let me bring that chrome window down here this is what happens when you do live presentations on chrome let me find where did you go uh let's go and i want to go move to built-in written display there we go let me just minimize that there for a second and there's my pet clinic application so we want to just view that there and i'm going to put it to the side there so that's my pet clinic application we should break it when we go find owners so find owners there and then find all owners there and it's broken so now we can actually see its farm to owners there and you get the variable view the watch view let me maximize that there and uh when you see there if we have um an inline display for our variables and this is a very new function so you can see there i don't even have to mouse over owner i can if i want and i get all of the view there but i get all of this nice inline view there and i can change that if i go into my variables view here uh i can go to local variables here and i can go there and i can go disable enable tostring object view so i can actually enable that there and then if i have a custom two-string view there and you can see there now i've got all of that new features there well i can disable that and there's a lot of other expressions there i can even go there add to watch and i can create watch expressions there so it's very similar to visual studio and eclipse it's got all of those functions there you can even go hot code to replace and this is a spring project so it does that automatically for me uh already and then i can step over and go into my normal functions and i'm gonna go uh continue and if we go back into our view here uh let's go back into that oh it's locked up there and i wanna go into the view and i want to go into that uh i'm going to just take the breakpoint off there and then let's go into that and there we go our our owners there so i can go into the edit owners and update those owners uh veterinarians there i've got all of those vets the found owners there and and then i i've got my application here so that that is the run locally on the screen dashboard and you can execute that with or with uh without debugging there's a lot of nice features with uh with uh debugging there so let's go back into uh our video studio code uh and let's just stop that um and own a controller now i've got my application so how hard is it to actually take this to azure now i've got the in the extensions view i've loaded in the extensions the azure extensions you can just go in there and there is a azure and there are azure tools you can just do the azure tools here and it includes all of the the azure you can see there the little windows that you get there azure app service storage virtual machine databases and screen cloud which we're going to do a little bit later so app service here i have created it beforehand and and i'm going to go create a new azure app service and all i have to do then is uh i'm going to go into the area there and i'm going to go right click and i'm going to go deploy to web app now i am logged in uh to azure and um so it's gonna it's already got my subscription so i'm gonna go add a config so you want to tell it uh what uh what you're gonna do what whereby you wanna do so i'm gonna say uh create a new basic web app there uh and i'm gonna call it uh uh matt's maths app uh and i'm gonna call my initials there also uh with rory uh with the rory matt's appetitory cool uh a runtime stack now this is spring so i can use just uh java 8 because remember we are running javad compatibility and i'm going to do embedded web server uh you can use tomcat at jboss um and then i'm going to use the p1 v3 production grade because i really uh i don't pay for this microsoft pays for it um and then i'm going to go into and it's going to create everything for me now i can actually go view everything that it's going to do there and i can go into that and while this is happening you'll see that in the azure uh the services here as it comes through i'll get all of that view there as it comes through under my subscription so it's creating the app service plan and a lot of this we're going to see when we do our second session where we go in and start to take advantage of the cloud services we're going to do order scaling we're going to do uh monitoring we're going to look at some networkings as support we're going to connect it to a database we're going to use terraform and azure devops with github actions to actually go in and create all of that so you really want to watch the next session but it's going to take exactly what we did with the spring pet clinic application and we're going to really juice it up on azure so we're currently application insights resource and the application insights uh is the monitoring tool that we use to use our distributed uh tracing and that's uh out of the box just works with uh your azure app service here and once we create the new way back we still have to go and deploy so it does the uh provision your resource into what how terraform works and then once it provisions all of those resources it's going to run through you'll see here it's going to run through the maven book now the same kind of maven install that we did there it's going to run through all of that right now uh i'll test that and at any given time we want to see exactly what's happening once that's created you'll be able to right click on that and go uh show me exactly uh what of you and i've already got the application running here which is uh which is great for while it's running you can just go uh we want to open up 8080 there and then that is going to run run through though so once you have that building you can just go and let's just go deploy anyway and we will go yes um you want to go right click there and you want to go start streaming logs and that will go through once that's going through there it will stream your logs connect to your log stream and and then we'll show you exactly what you're running there you can see there i've got my log screen there it's uh deployed uh my spring application it actually runs docker underneath it because it runs uh kind of like kubernetes implementation for app service uh brings up your instance there and runs it through there and you can you can go through all of this then we'll go through a lot of those services there you can see there i'm deploying to matt's appletory and you can check the output window it's going to zip up the application there takes about two to three minutes there it's already created the new uh web app and we can go refresh there and we should be able to see uh the actual application and if i go into opening portal uh you can see here let's just minimize that and let me get that into the other window um and there we go let me go and show you the app and now it's got my azure app service there and once that is uh done the deploys it's gonna bring up the browse the website let's give it a few seconds for the deploy to actually be deployed and and then you can see here i've got my maps applitori and uh everything is hunky dory and i'm not going to the uh the deployment center it should actually show me the deployment that i went through there so if i go to deployment center we're deploying from azure app service here and then i can go into loading deployment centers and and i can go into logs here and there's my deployment there from vs code and i can click onto that and then you can see there it's going through all of that deployment successful um and uh then i can go browse website and now this is running a built-in database i'm gonna show you in the next session how to run it with that and um yeah so there's your picture in the application it's as easy as that now if i go find owners uh i can go found owners and this is using a built-in h2 database here and this is all at the back end and i'm going to show you in the next session going to do the distributor chasing we're going to connect it to database we're going to uh scale it out though it's going to be really interesting so stay tuned with that and that's everything i wanted to show you today matt and i know this looks simple but it really is that simple we did the install i showed you some of the features we right click on the application and we just push it to azure it's really as simple as that yeah that was you did a lot in about 20 minutes so we've got the app up and running and then uh actually everything you listed out that we're doing in the next session was impressive uh scaling monitoring terraform devops um what's it just tell us one more time what's coming up next what we're going to do distributed tracing we're going to do auto scaling we're going to do devops as your uh app service we're gonna do terraform with github actions um and uh we're gonna take the exact same app and we're gonna pop it on there and i'm gonna show you how to really productionize that uh and uh just make a change uh and maybe i'll even show you uh github code spaces i will use data code space to do to do all of this and push it on there and do it and it's as seamless as that uh with uh connecting to a database with auto scaling and i'll show you that in the next session awesome i will have all the links down below in the description for folks who want to get the resources and try it out for themselves and looking forward to part two thanks so much thanks mate [Music] you
Info
Channel: Microsoft DevRadio
Views: 52,640
Rating: 5 out of 5
Keywords:
Id: 9Ce4qVcAKn8
Channel Id: undefined
Length: 25min 38sec (1538 seconds)
Published: Tue Aug 24 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.