Hi, everybody, my name is Joanne and I'm going to be your instructor throughout
this introduction to Java series in this series are going to learn everything you
need to in order to start programming with Java but before we get into the
meat and just start writing a Java program first let's review what Java is
so what is Java well to be a little more on textbook Java is a general-purpose
concurrent class base and object-oriented language yes that's a
lot of technical words in one sentence so let's break it down a little bit a
general-purpose language means it's not bounded to a specific domain some other
general purpose programming languages are C C++ Python. Concurrent means
multiple programs or part of the program can run in parallel. This is
going to be very much on into the future in a more advanced course where you
would probably learn about synchronization or multi-threading. Now
class-based meaning that everything within a Java program has to be inside a
class an object-oriented is a design philosophy and we'll get more into that
later on in this series another thing to know about Java is that it's intended to
let application developers write once and run anywhere this means that when
you have compiled Java code it can run on all platforms going back to our
general-purpose language and without the need for it to be recompiled
the only way this is done of course is that Java is supported on those other
platforms which means that you have to have Java installed now that's also true
for us in order to write our code so before we start programming we need to
download the necessary tools in order to build our Java applications let's
download our Java development toolkit or JDK for short so we're gonna go to your
search engine and you're gonna type
JDK download what I did it once before so JDK download here we go we're going
to Oracle's website. Now at the time of this tutorial
Oracle's latest version of Java SE is 13-point 0.1 just to be so that you guys
know Oracle owns Java. Java was written by a company called Sun Microsystems and
then Oracle bought out Sun woo 10 years ago
so now Oracle owns it and been updating it so the latest version right here we
have our Oracle JDK there's also something called open JDK if you are
familiar with that you can do that we're just going to stick with Oracle for this
tutorial so Oracle JDK click download so here's our Oracle SE developer kit and
we have our java SE development kit 13.0 that one before you can download you got
to click this obvious radio button to say that you accept the license
agreement and be sure to read the license agreement at least there's no
first board children being sold to or a call so if that's what you mostly care
about you're safe otherwise reader it make sure you're familiar with it in my
case I am on Windows as you can probably tell so I would download the windows 64
mini exceeds right here actually but I'm so save over it after it's done you're
going to install the software over your standard prompts so in this case we're
gonna run it and you can change the path or anything to you that you want put it
Program Files Java JDK remember the spot to go through your past install everyday
and and then get back to me once you are done
so after you've installed your JDK you now need an ID and ie e stands for
integrated developer environment it's what you used to program it you might
have used an IDE before in this tutorial I am going to be using IntelliJ but you
can use whatever idea you are comfortable with if you are not
comfortable in any IDE because maybe you haven't programmed much then follow
along with me and use IntelliJ otherwise feel free to march to the beat of your
own drum other popular Java IDE s are eclipse
IntelliJ like we're gonna be using and for some reason that beans is still out
there so then of course there's other ones other than those those are just the
top three so going back to my Google we are going to download IntelliJ so
IntelliJ intelligent download IntelliJ is owned by a company called JetBrains
so this IntelliJ IDEA it's an ID for our tutorial and for most of what you're
going to be doing all you need is the Community Edition so download the
Community Edition go through all the
save it run it go through all the defaults and I'll see you when you're
done
so after you've installed IntelliJ launch it alright so now we have our
welcome to in gelatin splash screen and you are going to create a new project so
here you go you create your new project your SDK will show up at the top here if
you've installed 13 it should be up here but for example I had 12 and 13
installed and 13 isn't showing up or for your case it was blinked but you know
that you installed the JDK you can do new and this is where you need it to
track of your path so in my case I already had my files in my F Drive for
my program files but yours might be on your C Drive using Windows or wherever
it's stored on your Mac so make sure I told you before to pay attention to that
path that it's installing to so go to that path that install to select the JDK
folder you'll see here I have some things called JavaFX
don't worry about those just look for the JDK so you should have a path called
JDK 13 that's your home pack hit OK now my project SDK is 22:13 Java version 13
dot 0 dot 1 alright we don't need anything else so we're gonna hit next we
don't need to create this project from a template so we're going to do next and
then we're gonna name our project so in this case I'm gonna name our project
intro jappa and this is where all the stuff that we're going to learn about in
this series are gonna go into this project path so we click finish now tell
Durden the fact that it shows us a nice little tip of the day you might want to
keep these if you want to you have an empty path so this is your intro to Java
you have your little project on the side you can expand it and now you have your
path here this is your source folder and this is where everything is going to go
alright so we are going to make our first program it's gonna be a very
simple program and we're gonna print out hello world yes I know it's the typical
thing that everybody does but it's a good way to test out make sure
everything that is working before we just go right into it yes you can make a
class file and it can go into a default package but we are going to make our own
package so you pray click the source you do new package now packages in order to
encourage that you don't have duplications you
we make a package name that is unique if you have a website you make it backwards
so you build up so calm so my case I have a website and it's called chaotic
chaotic toejam right so chaotic toejam calm so you do it backwards so be calm
dot chaotic no Jam no-one else owns the domain so it kind of puts back that
ability that it can be clash and then I could go even deeper so maybe I have my
Tech site could be dot text I'm not going to do that it's going to be just
calm day I Cho Jam and then in this case we have our intro Java and I want our
part 1 of the series we'll just call it part so this is just going from a more
general number to more general name to a less general name this prevents
conflicts and as you start introducing more packages and third-party
applications you can have conflicts with your package names so just a nice thing
to get inhabit us now now maybe you don't have a website so just be creative
it doesn't really need to be it sometimes I sometimes I just drop the
comb and actually like sometimes I just make it a default but in this case I'm
just going to do calm chaotic toejam so for you you can do whatever you want
heck you can even just put part 1 because we're not going to be merging in
any packages so you hit ok so now we have our new package placed in here you
can see it's great on the side and now we want to add in our hello world
project so right click this new Java class and we're gonna right
old capital H capital devil W alright double-click clacks and IntelliJ has now
created our HelloWorld dot Java file it's in the package calm chaotic toejam
part 1 and then they already define the first block for us our class basically
this is public class and the class name is hello world these brackets are
wrapping it into a block ok so this is going to be where all the definitions of
this class is remember I said that Java is a class based program this meaning
that everything that's with Java when you write it your methods your bits or
your functions I have to be inside a class in this case our class is hello
world so let me zoom in so our class is hello world now we are going to make our
main method our main method is the entry point to our program in Java the main
method has a very specific scent axis the header is always the same as public
static void name then it's string args and bracket it's like two square
brackets because this is indicating it's an array of strings and then we have our
space bracket and this is defining the block for our main method ok this is
this bracket curly bracket here to this end curly bracket this is the block for
our class so that's the code block for our class this bracket after our main to
the end here defines the code block for our main method so now we need to we
need to out print hello world before doing that I like to have a little
comments so let's learn how to comment in Java Java has a few ways to comment
one way is where you do a double slash and save just so in this case I'm gonna
write Just Blaze hello this beats gold well can't type today
displays hello world
alright um you can also do a code black this is star I am walk just to give you
guys an example this is a multi-line comment okay let's delete that so we
need to output to our terminal this in Java it's called instead of if
you're familiar with C++ or C you do see out or print at here we're going to do
something called system dot out dot
print and then we're gonna do print line you see here I have some suggestions
that are happening as I am typing this is an Intel a sense that is being done
by IntelliJ and they are suggesting methods or maybe points for the system
dot out like they're the parameters there and this is sending our parameters
so it's saying oh you can pass in an int you could pass on the character along a
float acceptor we're doing print line not print print line puts a line break
at the end of the out print so print line and we're gonna pass in a string
see here's our suggestions we could do no parameters that just doesn't empty an
empty line that gets printed out or in this case it has like a string X right
so we're gonna be passing in double quote for a string hello
face world semicolon semicolon at the end so the debris cap here we have the
declaration of what the pact our HelloWorld dot Java file is and it's in
package comm kogo Jam part 1 then we have the definition of our class every
Java program has to have at least one class remember class based each class
has a name and so in this case our name is hello world and by convention you
always start it with an uppercase letter then we have our main method the entry
point to our program this this is how the program gets executed this
decoration public static void main string args is the typical way to have
your entry point for your main method um then within your method you have
statements we have system.out.print line hello world and then a semicolon at the
end all statements have a semicolon which is known as a statement turn
terminator I mentioned before public and class are reserved words or key words
basically these are words that are defined for the Java program ok and if
we have other reservior to your public static void so we have created our
HelloWorld dot Java files let's run it and see how it works so we right click
and then you can say run HelloWorld main ok and their shortcuts next to it ctrl
shift f10 in my case you run this building the program right here
and here we have it out printing hello world
all right so congratulations you have just written your first program in Java
I'll be it simple it is the starting point and now we can now use these
lessons that we have learned which is creating a class creating a method to
now continue and improve our java skills