How To Code Java

How To Code Java


Hi my name’s Alex and welcome to my java tutorial for beginners. My goal is to help you become a great self-taught
programmer, so you don’t need any experience with these tutorials and
we’re gonna work our way from the ground up. My favorite question is why, so I like
to understand why we’re learning something and what’s in it for us. So I’d
like to start by making clear why we’re using Java, and also what Java is. I’m
gonna start with what Java is. Java is the world’s most widely used programming
language and it’s used to do about anything. Anything with a computer you
can do with Java pretty much. You can create apps, you can gather data, you can
create artificial intelligence, create a social media platform, really all this
you can do with Java. Question number two why learn Java. Java is actually really
easy to learn and it also has a lot of core programming concepts built into it,
so once you learn Java you can pick up any other language really easily like
Python C or really any programming language. It’s very easy to learn and
also a very valuable skill to have, so with that let’s get on with my Java
tutorial for beginners episode 1. Now to start coding in Java we need a place to
write code. I mean we could write code in Microsoft Word, we could write code on a
piece of paper but none of those ways has a way to run our code or see what
it’s actually doing. I made another video covering this and other basic coding
concepts that I highly recommend you go watch as well. It’s called how to code
for beginners in 2018 and I’ll leave a link in the card on this video and also
in the link in the description. So to write Java programs we need a place to
write our code, we need a way to start our code and we need a way to see what
our code is actually doing. One of the best applications to write Java programs
in is called Eclipse, so I’m going to show you how to install eclipse on Mac
and also windows so you can get started no matter what operating system you’re
on. So first go to the link in the description and this will take you to
the Eclipse download page for mac and windows. I’ll show you the Mac steps
right now and then we’ll go to the windows steps in a few seconds. So for Mac
make sure you have at least Mac OSX and then click this
Mac OS X cocoa 64-bit link and after that click the orange download button
and that will start downloading Eclipse for you. And this should take about a
minute depending on your internet speed. Once your downloads done open it up and
you’ll get this window with the Applications folder and the Eclipse icon. Drag the Eclipse icon into the Applications folder now open the
Applications folder and you should see Eclipse under the letter e and
you can just drag that to wherever your toolbar is I like to have it on the left. And so now we can just close everything out and now open eclipse from the
toolbar and if you get this you can just hit open. And now you should get this
pop-up Eclipse launcher. And this says select a directory as a workspace. So a
directory is just another name for a folder like, on my desktop I
have a finances folder, I have a projects folder. A directory is just a folder. And
a workspace is like where our projects are going to be saved to.
So it’s asking us for a folder for where it wants to save our work. To
make it simple I’ll save it on my desktop because I like to have things on
my desktop. Click desktop and create a new folder and I’ll call it Java
tutorials, like that. Ok so now we have our Java tutorials on the desktop and
that’s our workspace so wherever we save our Java files to it’ll save it here. Ok
and once that’s done you can say use this as the default and don’t ask again
and after that hit launch. So after that you’ll have this window. We can make this
bigger and this is just the welcome screen. It has links to things that
doesn’t really apply to us right now so we’ll just hit the close on the welcome
screen and this will come up. This is the place we’re gonna work in and I’ll
explain the important things here in a second. Now I’ll show you how to install
it on windows. To install Eclipse on windows you go to the same link and
yours is going to be the windows two bit or 64 bit links. To see if your
computer is 32-bit or 64-bit, you type ‘system’ into the search bar and under
‘system type’ you’ll see 64-bit operating system or 32. So get the one that
corresponds to your computer. Mine’s 64 so I’m going to download the 64-bit
version. And hit the orange download button. Once that’s done, open up the
folder that it’s saved to and right-click it and press extract all. And
then extract. Now once you’re at this link if you have 32-bit click this one
the 86 and if you have 64 click the 64. And that’ll download too, but first you
have to accept the license agreement. Then download it. When that’s done run it
by just clicking it and this will install Java for us and I’ll click Next,
Next and hit OK, next. When you’re done you get a pop-up, hit close and you
should be good. So open up that downloads folder again go to the Eclipse folder
not the zip folder but the folder you extracted to, and open eclipse. Now you
want to select your workspace and this is just a folder on your computer where
we’re gonna save our files to. I’ll do this on my desktop just like I did on
Mac. I’ll create a new folder called Java tutorials and I’ll choose that one, and
hit launch. Now we get the welcome screen, we can close that, make this fullscreen
and now we have Eclipse installed on windows. So now you should have a screen
that looks like this, you have some white boxes, some buttons and if it doesn’t
look like this, say it looks looks kind of weird for whatever reason, you can go
to window>perspective>reset perspective. And this will change
everything back to how it was when you first installed it. And also all the
steps on Mac should be very similar to what you’re seeing on Windows. I believe
the best way to learn how to is through examples and through playing
and exploring on your own so I’m not going to explain every little detail
about Eclipse to you because it’s not important, but what is important is
walking through examples, so I’m gonna start an example. To start writing code
in Java, go to File>New>Java Project. A project is pretty much just a collection
of code. So it’s our collection of Java code that we’re going to be writing. So
click Java project and this should bring up a new window that says new Java
project and here we can create the project name so we can say something
like swag and use the default location which you’ll see grayed out it should be
on your desktop or whatever folder you set at the very first step. So our project
swag is gonna be saved there and then ignore everything else the only thing
you need is your project name and then here next and then hit finish.
Now this created a new project for us you see on the left here, we have our
Java project and we can open it up. And then you can right click this this icon
called SRC and hit new class. And now we can name our Java file and I’ll just call
it Java tutorial. Next go down to this section that says which method stubs
would you like to create and then check this first one here. Public static void
main, that one. And that should be good. And then once that’s done hit finish and
this will create sort of like an outline for our Java code. And now take your
hands off and now I’ll explain what we just did. This left area, with all these
little icons, this is just a file explorer. So if we go to our desktop and
go to Java tutorials, we have swag and we have source and we have Java tutorial.
This is the same thing. We have swag we have source we have a few extra things
but we have Java tutorial. So it’s just like a different way of seeing the same
folders on your computer. So if we add in a folder here and we refresh this
by right-clicking and doing refresh, you’ll see the new folder with a
different little icon. So it’s just a different way to see the same thing. So
we can delete it and refresh again and it’s deleted from here too – now I’m gonna
shut up and we’re gonna writing code. This right here was all generated for us and
I see a program like a customizable car. This is like a very basic car. It has an
engine, and it has wheels but to make it our own we got to add to it. Today we’re
gonna write a Java program called ‘Hello World’ and it’s the first program that
pretty much everyone learns. It was the first program I learned. And this program
writes the words ‘hello world’ to the screen. Now there’s a lot going on when
trying to put text to a screen but Java turns it into just one line of code.
Don’t worry about what any of the symbols means, don’t worry about what
this means, don’t try to memorize any of the typing. The real way to learn how to
code is by playing with examples and you’ll start to get the patterns over
time. You shouldn’t be memorizing anything, you shouldn’t be cramming stuff
into your head. Just play with examples and it’ll come more naturally. Okay first
thing is click on line six and type the word system with a capital S. ‘System’ then
a period, then ‘out’, another period and then p – r – i – n – t – l – n. Ignore all of this
stuff okay. Next type an open parenthesis, double
quotes and then type ‘Hello World’. Okay then you can use your arrow keys to move
to the end and finish the line by pressing the semicolon. Now to run our
program, save it you can do command-s on Mac. It’s also ctrl-s on Windows and I
have a live shortcuts, down there that’ll show whatever shortcuts I’m using in
real time for you. Now to run this program, go over to the green circle in
the top left and click it. And that will run the program and then in this console
window we see ‘Hello World’! It put text on the screen for us,
with just one line of code. Now what you probably noticed is that, the text that
came out on the screen, is the exact same text that was in these quotes. So you can
change this to anything, save it again, run it again, and it’ll print that text
to the screen. So you can have fun with it you can say like, you can type your
name. Look and now you just become really cool. So like just play around with this,
you can type really whatever you want you can make it really long, so you can
like copy this, command-c or ctrl-c, enter and then you can type a lot of
these. Save, run and it’ll type more. You can print patterns to the screen, you can
type like a whole essay if you wanted to. But I encourage you to play around with
it. So I hope this was interesting, thank you for watching my java tutorial for
beginners. If you enjoyed this or you think this might help someone else learn
how to code in java, please leave a like down below and share the video. I’ll also
leave notes from this video in a link in the description down below as well. You
could be anywhere in the world but you’re here with me and I appreciate it. Catcha!

60 thoughts to “How To Code Java”

  1. when I tried to launch eclipse, my mac just said this, "ALERT, failed to find a main class in '/Applications/eclipse.app/contents/MacOS//…/Eclipse/plugins/org.eclipse.equinox.launch_1.5.0v20180512-1130.jar" how do i fix this

  2. This was a really helpful video, too bad you don't have a second part to this. My professor sucks at explaining Java, Eclipse etc. So it's been difficult for me to understand and learn all of this.

  3. Hey Alex! Thanks for the video I am trying to learn programming (self thought) and your video simply answers all my question, thanks again and I'm one of your fans now (I've just hit the subscribe button) thanks again see you in your next tutorial..Cheers:)

  4. This is exactly what i was searching for. I just had little bit trouble figuring out how the running in eclipse works but anyways, Awesome Tutorial!

  5. This video is awesome, thank you so much! I can tell that you put a lot of time and effort into this, because you explain everything thoroughly and clearly, which is what I think everyone needs. You deserve way more subscribers, and keep up the great work!

  6. After watching this first video, I subscribed to your channel and looking forward to your next videos. I took computer programming for the first time and the instructor on Java went way to fast. Instead of learning what he was teaching, I was too busy trying to keep up and when I was caught up, I was like, "what the hell did I just do".

  7. Okay, not to be rude but System.out.println(string); is not teaching Java.
    The only thing you taught them is how to install Eclipse, which I would prefer IntelliJ over anyday.

    If you're going to teach Java then begin with the basics
    Methods
    Booleans
    Strings
    Integers
    Statics
    Private vs Public
    etc.

  8. When I clicked on the link to Install Eclipse for Windows it said "This package was released on 06/27/2018. A newer package is available" so should I download the new one or the package in the link?
    Please Help

  9. Hello! Thanks for the great tutorial. I was just wondering if I should install Java SE Development Kit 8u211 or like java development kit 12 or something? I was also wondering if I really need to do an oracle account to download the development kit? cause I always get a pop up window where it says that I have to login to my oracle account. Thanks for the help!

  10. Hello Alex. I like your teaching style. I would like to offer a suggestion. While it is nice that we can see you, the keyboard and your shortcuts, the code you are entering is almost unreadable. Too small, even on my biggest display. It's hard to follow along when you cannot see clearly what is going on. So as a suggestion, zoom in on the code when entering it, or when changing settings or clicking on menu items. It would be real helpful to see things much closer up. I hope you continue to put out the videos and be more regular at it. If you want your channel to grow, one key is to keep putting out videos, at least one a week. You can see on my channel that I have hundreds of videos. It takes time but soon you'll be able to monetize this channel well. 🙂

  11. Would like to hear your thoughts on this programming language, https://www.youtube.com/watch?v=eOloWnPBC1M. I think it's new but I'm not really sure.

  12. Hello Alex! I have a problem with the download link, wheni click on the JDK download it takes me to a page where i have to log in. Please help me. LG Alex (my name is Alex too)

  13. I've watched a bunch of your videos and like your style of teaching. You can help so many HS students (and new CS teachers like myself) if you create and/or reorganize your videos to follow the AP Computer Science 'A' curriculum of concepts. There are thousands of Java tutorials (great!) on YouTube but I have yet to find the tutorials that are geared specifically for the AP CS-A class. Go to the College Board website, find the class, and look to see what specifically the AP class focuses on, their projects, etc. Wouldn't you like to have every AP CS-A student worldwide like and follow you?

  14. i am from india and i am in third year persuing my btech degree in cse and i want to get a good placement but i dont know hot to code and after watching this video i am really confident.

  15. i was going to take a computer science class at a community college and it was almost $800 after paying for everything, fuck that!

  16. I have no prior programming experience and just started a computer science course in college. This channel has made my life so much easier! When i don't have time to sit with my professors at office hours i can watch these videos and it clears up any questions i had about coding in java.

  17. btw I have win war which is basically a 7 zip or archive thing windows and because I have that, extract all won't show up. Can you tell in comments on how to use it with win war or something? 4:54

  18. I keep getting this error when I try to run my code: "The selection cannot be launched, and there are no recent launches." Any advice?

  19. i know this is a kinda old video but thank you so much! i was trying to find were to code for so long and the fact that this video is so easy to follow is amazing thank you!

  20. These videos are really helping with my study my tutor isn’t the best and it’s hard to stay focused for 2 hours at a time listening to him so being able to come home and use these for study is super helpful

  21. I figured it out

    Hi ! I am struggling to install eclipse and java on Windows. I tried to follow the steps, while getting the newer versions (for some reason your version needed me to create an account, I saw some people had the same issue). When I go to the extracted eclipse folder to open the app, it says that i have no JDE or JDK installed because it's looking for it in the extracted folder (I think). Here's the location it searching in : C:UsersNicolasDownloadseclipse-dsl-2019-09-R-win32-x86_64eclipsejrebinjavaw.exe
    Should I try to move my java folder there ? Should I get your versions ?

    Sorry for the long comment, hoping for an answer 🙂
    And thank you for these videos, of course, I'll follow through them carefully once I get this over with

    Edit a few minutes later : I tried the Eclipse installer and I have now eclipse open, but I still get error messages when trying to run code :

    Error occurred during initialization of boot layer
    java.lang.module.FindException: Error reading module: C:UsersNifilDesktopJava Programsyesbin
    Caused by: java.lang.module.InvalidModuleDescriptorException: tryOne.class found in top-level directory (unnamed package not allowed in module)

    I guess my original problem is fixed now, I have to solve this one.

    Final edit : I solved the problem above by deleting the info module that was automatically created. I guess I'll leave this comment as info if anyone needs it.

Leave a Reply

Your email address will not be published. Required fields are marked *