Introduction to Java : Java Programming Tutorial

Introduction to Java : Java Programming Tutorial
Introduction to Java

Welcome to this Introduction to Java Programming tutorial.

We will see step by step how to create programs with Java. This tutorial is for anyone new to programming or for anyone looking to learn the basics of Java. 

At the end of this tutorial, you will be able to write a program with the help of Java to solve a given problem.

You will be able to think about the solution to put in place to translate it into a program and run the execution to see if it meets your needs. A program is simply a list of instructions written to solve a problem, or to perform an action.

You should know that the computer only understands 1s and 0s, so it is difficult to speak with it. In this case, it is necessary to use a translator which is a programming language. A language, which understands what you say to it, converts all this into 0 and 1 perfectly understandable by the computer.

And Java is part of this programming language family.

It was created in 1995 by Sun Infosystems which was later bought by Oracle in 2009. The language is created for use in embedded systems. But now most find it in the software, the web application, the mobile applications, etc.

The language benefits from excellent portability: once the program is created, it works automatically everywhere (Windows, Mac, Linux, etc.). Java programs don't even know where they are running, as they do so inside a special software envelope called a Java Virtual Machine.

Java went under the open source license GPL license in 2006.

Why learn Java:

  • Its great success in the 90s;
  • The very rich, varied, and mature tools at their disposal;
  • It's a very large community, which makes it easy to find help if needed;
  • Its ease of handling.

To create a Java program that works, you need to go through the following 3 steps:

  • Write the program and save it to a file.
  • Compile the program to transform it into code understandable by your computer
  • Run the program.

We are going to write our first program which will be to ask the computer to say hello.

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

Don't worry, I'll explain how this program works a little later in the tutorial.

We will compile the program. If all goes well we will have a helloWord.class file which will be generated and will contain the binary code commonly called bytecode. 

If there are syntax errors in your program, for example, if you forgot the last closing brace, the Java compiler will display an error message. You will then have to correct the error and recompile the program. If there are several errors, you may need to repeat these actions several times.

Now we can run our program which will display Hello World !.

We will also use JShell which will allow us to easily test different Java functionalities, without having to create a whole program for that. It's a big-time saver!

jshell> System.out.println("Hello Termux");
Hello Termux
jshell>

In this tutorial we have set up the basic tools for writing, compiling, and executing Java code. In our next chapter, we will see how to get started with Java starting with variables and data types.

Next Chapter: Variables and Data Type in Java

Post a Comment

Previous Post Next Post