Learn Java from the Beginning

Dilka Sithari
LinkIT
Published in
6 min readAug 17, 2022

--

Photo by Christopher Gower on Unsplash

Welcome to my first article on java.

Java is a high-level programming language.

Java is,

  1. Free and Open Source — Once we install Java, we can start working with it.
  2. Cross Platform Compatible — Java can run on any operating system such as Windows, Mac, or Linux. We can run the same java project in whatever operating system we have.
  3. Object-oriented — Can represent all the objects from the programming point of view.

To start learning Java, first, we need to download java JDK for our computer.

Let’s see how we can download JDK,

First, just search for download JDK from your browser as shown in image 01.

Image 01

Then click on the first link in the search results. When scrolling down we can see JDK downloadable links for Linux, macOS, and Windows as image 02.

Image 02

Click on your operating system. My Operating System is Windows, so I click on Windows. Then it will display as in image 03.

Image 03

Now click on the link in the 64-bit installer as image 04.

Image 04

Then JDK will start downloading to your computer.

For your ease, I just paste the link below,

JDK Stands for ‘Java Development Kit’ which means a kit for programming all Java concepts and a kit that helps to create and execute programs.

Let’s set up Integrated Development Environment(IDE) for Java. Now here we download and install Eclipse.

Eclipse provides a proper platform or proper development so that we can code in a very easy way.

To download Eclipse go to the below link.

Click on the download buttons respectively as in images 05 and 06.

Image 05
Image 06

Then it will begin to download.

Next, let’s install Eclipse on our computer.

When downloading is completed double click on Eclipse exe file. Then image 07 like window opens up and next click on Eclipse IDE for Java Developers.

Image 07

Next click on the install button. Then the installation process will begin as image 08.

Image 08

Then below window open up as image 09. Click on Accept Now button.

Image 09

Then it starts installing as image 10.

Image 10

Then click on the Launch button as in image 11.

Image 11

Now downloading and installing are completed. Here browse a location to save the projects, then click on Launch as image 12.

Image 12

Now let’s create our first java project on eclipse. Click on file, new, java project as image 13.

Image 13

Then below window open up as image14, so we need to give a project name. Here I give the name test_project. After giving the name click on the finish button.

Image 14

After that, another window opens up as image 15 by creating a module name. There click on create button.

Image 15

Now we have successfully created our java project.

Inside our project, there is a source folder. All the codes we are creating are exited inside the source folder. Then we need to create a java package. For that, we have to right-click on the source folder, then click on the new, package as image 16.

Image 16

Then another window opens up as image 17 and asks for the name of the package. I keep the package name as test_project. Then click on the finish button. Then it creates the package named test_project.

Image 17

Next, we want to create a class. For that right click on test_project package then click on new, class as image 18.

Image 18

Then the window opens up as image 19 asks the name of our class. Here I give the class name as TestProject.Then tick on the box in front of the public static void main (String[] args). Then click on finish and it creates the java class as TestProject.

Image 19
package test_project;public class TestProject {
public static void main(String[] args) {
}
}

Everything we see around us is an object. Class is a blueprint of an object. Everything inside java needs to be inside a class. In this example class name is TestProject. Generally, the name of the class starts with a capital letter.

Public is an access modifier. A public class can be accessed by everyone which present in the program.

Inside the class TestProject, we have the main function. Void is the return type of function main. Every function has a return type associated with it. The public keyword implies that this is a public function and the static keyword imply that this is a static function. Static function can be accessed without an object. If we did not add static before a function we need an object to invoke that function.

Let's write our first java program. Inside the main method, we include System.out.println(“Hello World”); .

package test_project;
public class TestProject {
public static void main(String[] args) {
System.out.println("Hello World");
}
}

When we run this simple program it prints Hello World.

Hope you enjoy my article. If there are any concerns please comment on your idea.

Thank you.

--

--

Dilka Sithari
LinkIT

Final Year Undergraduate at Faculty of Information Technology, University of Moratuwa, Sri Lanka.