Java Tutorial

Java is a general purpose, high-level programming language. Java was originally developed by James Gosling at Sun Microsystems and released in 1995. However, Sun Microsystems was acquired by Oracle in 2010.

James Gosling is also called the father of Java Programming Language.

Java is used for building desktop GUI applications, web applications, mobile applications, and various kinds of small and large complex applications. However, Java was originally designed for use in digital devices like digital cable television setup boxes. But Java was so advanced that Sun Microsystems decided to use it on different platforms. Since then, Java has been evolving with powerful capabilities and has become one of the most popular programming languages of today.

Why should you learn Java Programming Language?

Java is a very powerful programming language. Java allows a developer to create a program that can do almost anything in the computing world. According to Oracle, around 3 billion devices run on Java. Following is the list of features which makes Java a great Programming language:

  • Simple and easy to learn — The code syntax of Java is clean and easy to understand.
  • Object-oriented — Java is an Object-Oriented Programming language. Everything in Java is built using objects. An object is a virtual representation of a real world thing that has states and behaviors.
  • Robust — Java is robust because it is capable of handling errors during execution of the program.
  • Secure — Java is considered more secure than other programming languages because it runs in its own virtual machine sandbox, an environment provided by JVM. JVM is short for Java Virtual Machine. It is a virtual machine that helps to run Java code that is compiled into bytecode. Java compiler converts the Java code into bytecode (.class file) and this bytecode can be executed by the JVM. When this bytecode are executed, the JVM can take care of the security.
  • Platform Independent — Java is platform independent which means java code can run on any operating system.
  • Architecture-neutral — Java is architecture-neutral which means Java compiler converts Java code into architecture-neutral object file (bytecode) that can run on many processors, given the presence of Java runtime environment.
  • Portable — Java is portable which means the compiled Java code (bytecode) can be moved and run on any Java-supported platform without modification.
  • High performance — Java uses JIT (Just-In-Time) compiler to convert Java bytecode into native machine code at runtime. This improves the performance of a Java program.
  • Interpreted — Java code is first compiled into bytecode. This bytecode which JRE (Java Runtime Environment) can understand is then interpreted by the JVM.
  • Multi-threaded — Java is a multi-threaded which means Java code can be written to handle multiple task simultaneously.
  • Dynamic — Java is dynamic which means behavior of a Java program can be changed at runtime. Java is dynamic as it loads class files (bytecode) at runtime.

Example of a Java Program

Here's is a simple Java program to print Hello World where MyFirstProgram is the class name and main is the method name:

public class MyFirstProgram {

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


The output of the above code will look like the following:

Hello World

Four Different Editions of Java

There are four different editions of Java defined by Sun Microsystems for different platforms:

  • Java ME or Java Platform, Micro Edition — designed for use in small portable devices like mobile phones.
  • Java SE or Java Platform, Standard Edition — designed for use in developing desktop applications, games, antivirus, and other different kinds of applications.
  • Java EE or Java Platform, Enterprise Edition — designed for use in developing large internet based web applications.
  • Java Card — designed for use in SIM cards of mobile phones, ATM cards of banks, and other small devices.

Important Terminologies in Java

Following are some of the commonly used terminology in Java that you must be familiar with to understand the Java Programming Language:

  • JDK — stands for Java Development Kit. It is a software development environment required for developing applications using Java programming language.
  • JRE — stands for Java Runtime Environment. It is required to run Java applications.
  • JVM — stands for Java Virtual Machine. It is a virtual machine that helps to run Java code that is compiled into bytecode. JVM is architecture dependent which means there are different implementations of the JVM for different Operating Systems.
  • Java Compiler — compiles human-readable Java code into bytecode.
  • Java Bytecode — is an intermediate code which are compiled from source code.
  • JIT Compiler — compiles the Java Bytecode into machine-readable code.
  • Garbage collection — is the process of finding unused or unreferenced objects from memory and removing them to free up memory in Java.