[MUSIC]
>> Greetings everyone
and welcome back to the Java for Beginners series.
My name is Brian Benz,
I'm a Cloud Academic at Microsoft,
and I'm joined by Rory Preddy
who's going to talk to us about Visual Studio Code.
Rory, do you want to tell us
a little bit about yourself and about the topic?
>> Thanks Brian.
I'm talking to you from Johannesburg,
South Africa, and today we're going to show you
three things to get you started.
One, how to install Visual Studio Code.
Two, how to navigate all the menus
and get started with your project,
and three is how to push to the Cloud of choice; Azure.
I'm really excited to show you those three things,
and by the end of this you're going to be able
to use Visual Studio Code and Azure.
Hello friends and today we're going to
be going through some very basic
install guide on how to get started with Visual Studio Code,
and also looking at running
and debugging your first application
and running J show in the terminal.
The first thing in the links provided,
you're going to install the coding pack for Java.
You'll get on install a disclaimer
to accept the license agreement.
Click on "Next", it'll scan what your requirements are.
You can see there I've already got JDK
and also the Visual Studio Code
installed and then click on "Install"
for it to install your requirements,
and then click on "Finish" to launch Visual Studio Code.
You'll be given a blank screen here so let's just maximize that,
and you'll be given a blank screen here
and you can start or either Open Folder or Clone Repository,
and we're going to go in and create a Java project.
Now, we're not going to use any build tools.
You can use Maven, Spring Boot,
Quarkus, and MicroProfile if you want to play around,
but I'm going to click there;
No build tools,
to go with a sample project.
I'm going to specify a basic project
that I'm going to start with,
so I'm going to call this javabasicsmsft
for Microsoft foundation,
and then select the project location
there and give it another name there.
I'm going to call that javabasics.
Then you have a very basic file that has been created;
you can see there App.java,
and if you run that file it is
just going to say a "Hello, World!''.
You can click on that little run and debug.
Run and debug, and just make sure that everything
is set up correctly there.
Now what it's going to do here it's going to use your JDK
that is installed with the coding pack,
but you can actually change it to install it
or to install another Java Development Kit.
If you go into the Command Palette;
so you go View, Command Palette,
we have a screen there called Configure Java Runtime.
You can click on that
and in there you'll see the project data case.
Default is the Java 11 JDK that comes with
the Microsoft OpenJDK just recently released,
and you can also specify the tooling runtime
which is the language server.
The language server actually does a lot of
the passing of the the language features in the background.
You can specify that there,
and also get a view on your install JDK.
As you can see there, I've got 16, 15, 11, and 8.
If you want install a new JDK,
you can install an AdoptJDK here
or you can go and click through others.
You can see there there's the Microsoft Build of OpenJDK.
I've got App.java, let's create a program using
the really great IntelliSense that is provided out of the box.
The first thing I want to do,
is I want to delete that line there
and then I want to create a person object.
Person p equals to new,
I'll write there at Person.
I'm going to give that person the name of Bill Gates,
the Founder of Microsoft.
Then I want to go P.
Let's go sysout
which you can see there it's got some nice template sysout
and I want to go p.getName to get the name,
and then I also went to go "Hello, Bill Gates."
We do that and then we'll just make sure we've got a space there.
Now it's complaining to us that that person clause doesn't exist,
even in the file view there you can see when you got App.java.
We're going to scaffold out that using the IntelliSense.
You can master the person here,
and then you can just go there.
You can see Person p cannot be resolved to type.
You can click on "QuickFix"
and then you can go Create 'class Person'.
It'll create the class there and template it out
and there's really nothing in that class just yet,
then it will say the constructor.
You can see Person p is not available,
so we can go QuickFix
and then you can go Create constructor.
Now if we're going to the person plus
there it's got a constructor.
Lastly, we want to the getName,
so we can do a QuickFix and then Create method getName.
Now if we run this, it won't really run anything
because there's nothing set up in the name.
We have to go in and just wire it up,
so we want to create there a private string name
and we want to set that name when the constructor
goes in to this.name.
We'll set this.name,
so it's the instance of the class being created equals to name.
When we get the name there we want to return
name for the getName method,
and finally we want to use the great refactoring tools;
the Source Action there.
You go to Source Action,
and then you want to go generate a toString method there.
It'll say what fields do you want to use,
you click "Okay".
Then we'll say, "Yeah, that is the person.Name.
That's our class done for personal class,
now we want to see it run.
If we run it now and we haven't put any breakpoints,
you can just go run and debug.
It should say Hello; there we go, and Bill Gates.
Now we're going to put a debug pointers.
You can just click on, on the getName here;
the debug point and we want to actually debug this class here.
You can click on Run and Debug again,
and it should stop where we put our debug points
and now it's using inline variables.
You can see there the inline variables are
person name equals Bill Gates,
and you can change that.
If you want it to you can right-click
on the variables names there,
and you can go Disable 'toString()' Object View
or a lot of different options they had static variables
and you can actually change it.
You want to then step over
and go to the next line where you can step into.
If we go to step into here then you can get step into here,
and you can see that this is going into the Java classes
and you can step out of to go back
and step over to go through there
and then we have there the run continue to say Hello Bill Gates.
Last thing I want to show you is how to run a JShell,
so you can go JShell here in the terminal
and it'll give you the Java show.
A lot of our demos that we're going to run in this series
I'm going to be using JShell.
You can get JShell here
and also obviously run the classes as we've shown you here.
That's everything I wanted to show you today,
so go to that link install the coding pack for Java
and then get started.
Create your Bill Gates object, your person object,
and then we'll see you in the next sessions.
>> Thanks Rory.
That was great.
>> Thanks Brian and we shared so much
with the audience on Visual Studio Code.
>> Please don't forget to check out
the rest of the Java for Beginners series.
[MUSIC]