Java 1 tutorial for beginners. Install eclipse and First program

Uploaded by edu4java on 05.06.2011

Hello, I´m Eli for edu4java and this is the first Java tutorial
We are going to develop our first java program
from zero
The first thing we are going to do is to download java
We are going to write in Google "Java"
and "jdk"
which stands for "java development kit"
It is the development kit for java
Here we can see the Oracle site
Let's click here
We find "development Kit 6u21
We click "download"
Here we have to select the operative system; we choose "Windows"

Below we click "continue"

we click in this file here
75 MB
And here we have the possibility of saving
I already have it saved so I am not going to download it again
But you can save it and automatically it is going to download
Once you have it we are going to look for an editor
We can write it in a text editor like "notepad"
But if we download "Eclipse" it will help us
to write java code. Everything will be easier.
Because of this we are going to use Eclipse which is free
Let's see, we write Eclipse and we go to
We go to "downloads"
We have several "Eclipse" versions
Any which says "java" is ok

The ones which say "java" are perfect. The ones which say c++ or php aren't useful for us
I always use this one
Here you can download it for "Windows 32 and Windows 64"
We are going to choose 32 bits
We click here to download
and again it gives us the option to save
I'm going to press cancel because I have already download it but you press save
After a while you get these two
this is java
and this is eclipse

This is an exe so it is simple, you press, next, next, next and you will install java in your computer
This one
is a zip file; it is compressed
If you don't have a program to
You go to Google
and write "winrar" for example which is the one I like
"Descargas" (downloads)... WinRar España
and the first one
is ok
You click here and you get this small exe
You are going to have this one. Double click and you install it. Once you install it
You can do double click in this file and
you are going to be able to unzip this. Inside this file you are going to have an "eclipse" folder
You can drag it anywhere

anywhere you like in your computer

I've put it in the desktop so it is more visible for you. You can put it in C or any place
Once we have it unzipped
Here in the file we have eclipse.exe
This is the editor
Double click
and you initialize the editor
It is asking for
a workspace. It wants to know where to leave the generated files
By default this is where it offers to put it. With browser you can choose to put it wherever you want
Now it is loading for the first time
here we are
This is the editor
We are going to start creating a new project java
Right button over the area of package Explorer- new- java project...
Let's name it
we press finish
and here we have our first project "holamundo"
We open it and we can see we have a folder
called source.
This folder is going to contain
the files with the code of the programs we are going to write
Right button- new
Now we are going to create a Class

The Class we are going to create
has a name

It starts with upper case
due to convention. You can write it with a lower case but
the java community and the standards advise you to
write it with upper case
Another convention says that when there are two words
Or one word made of two
The first letter of the last word goes with upper case. So here in "HolaMundo"
"M" goes with upper case. If we wrote "HolaMundo" and another word, the next word will be also written with upper case
with this checkbox
we can generate automatically
the main method
Which we are going to need to execute this Class
Once we have written the name and we have selected the main checkbox
we go to finish
and here we have our class
Here a file has been created inside the src folder
here we have a file
This called "default package" will be explained a bit later on
This is file .java which will have the java code
This is the code inside this file
This are comments. We can delete them to make things easier
What we are going to see here is,

first of all the class
public class "HolaMundo"(Hello World")
a brace which opens
If you make double click here we are going to see where it closes
All this in blue is what is inside "HolaMundo"
Inside "HolaMundo" class we are going to find
this which is a method
public static void main: this is the method we asked the editor to write for us
This are arguments

We will study them later
Don't worry

And again we have braces which open and closes and inside
we are going to write

the program

We are going to write "syso"
And we are going to press ctrl+space and automatically Eclipse helps us and generates this instruction
This instruction
Says that whatever we put inside here is going to be printed
in the console. This is the console
Let's clean it
This is the console
If we write here between quotation marks "edu"

we come here
Where it says "Run HolaMundo" we click
and automatically
the method main was executed
The main method has this instruction inside which prints in the console "edu" and here we can see "edu"

If we change and write "Hola mundo"

We run it again
and we can see "Hola Mundo"

We can add more instructions

"hola edu"
"Hola Mundo" and "Hola edu"

If you were able to
follow this tutorial
I congratulate you; you have just learned how to make your first java program

Thank you for listening, see you in the next tutorial!