Java

Introduction to Java

This Introduction to Java focuses on knowing the Java Programming Language. We will cover what are the major characteristics and components of Java, why it was invented, and a brief of the history. The Java Tutorials series focuses on Learning Core Java and some of the very basic as well as advanced features of Java Language. In this first article of the series lets get introduced to Java Language.

Overview

Java is an Object Oriented Programming language which is alive for years and still holding the top spot in popular languages chart. Since invented, java has been empowering number of Enterprise Applications, Microservices, Desktop Applications, Mobile devices, and embedded devices. Java has great adaptability and it can be used in variety of the requirements as first choice language.

Java was developed at Sun Microsystems by James Gosling and initially named as Oak. The reason behind yet another programming language was some of the API shortfalls of C/C++ and a need of portable programming language. As Java was developed as an alternative to C++ its syntax and programming style is totally inspired on C++ and also supports Object Oriented Programming standards.

Popularity

Java is one of the most popular and widely used Programming Languages in the world. According to recent developer survey done by stackoverflow, 45% of world professional developers use Java. The the below chart.

Language Usage (%)
JavaScript 71.5
HTML 69.4%
CSS 66.2
SQL 58.5
Java 45.5
Bash/Shell 40.4
(** from stackoverflow developer survey 2018)

The first 3 of the list are JavaScript, HTML, and CSS which are widely used for browser languages. Which means they run in the browser. The 4th on the list is SQL which is not a programming language but a language to manage persistence layer. This clearly indicates that Java is the most popular general purpose programming language of the world.

Characteristics

Java is primarily known for its cross-platform abilities, that is Write Once, Run Anywhere (WORA) behaviour. Which means, a Java program can be written on one machine (operating system) and can be run on other without having to change. It used widely used to develop Desktop, Web, Mobile and device embedded applications.

Along with above below are some of the major features of Java Programming Language

  • Simple: Java was intentionally made simple. The syntax is kept similar to C++ to reduce the learning curve. No need to deal with pointers and JVM will manage the memory smartly. Having garbage collectors no need to explicitly de-reference an object in order to destroy it. No complex features like Operator Overloading.
  • Cross Platform: No matter which machine, device you are on, you write the same program. Java doesn’t have any coding constructs those are coupled with the underlying hardware or platform.
  • Secure: Java is considered secure language because it keeps the object and memory management to itself. Developers can’t manipulate the memory pointers. The Java bytecode verifier and class-loader verifies if the class being loaded is the correct one with legitimate bytecode.
  • Portable: As discussed at the beginning of this section once compiled into the bytecode the javea program can be transferred, sent as an email, or downloaded from internet and run on any machine without any issue. This is why we can develop application on our mac or windows machines and once the project is built we can easily ship the archive to the production environment which is mostly a unix based system.

Object Oriented

What is an Object Oriented Programming Language?

In Objet Oriented Languages, the main importance is given to Objects. So what every you cod you write objects. When we write real world programs we mostly model the real world entities and while we do so we need to represent them in the form of Objects. Java is one of the Object Oriented Programming Languages.

In Java each object has some properties. The properties define state of the Objet. Along with the properties, the objets also have behaviours. Behaviours are represented in the form of methods. Behaviours mostly access or change the state of the object or invoke behaviours of other objects.

Java is considered Object Oriented but it is not purely object oriented. Java has few primitive datatypes (e,g, int, float, double etc), which are not objects but a special purpose datatypes. Another thing is static variable. Like primitives the static variables do not follow the Object Oriented paradigm. This is why Java is still not fully Object Oriented Language.

Write Once, Run Anywhere (WORA)

When a program is written it is usually a textual, and human readable. We need to compile this program before we run it. Each language has a compiler which first of all validates your program for any syntactical mistakes. Once your program is correct it will convert the program into more machine level program. (remember: to run your program it needs to be transformed into Operating System and Hardware level instructions).

In most of the programming languages including C/C++ the Compiler is the one who converts program into machine instructions. However Java thought it differently. Java created a virtual machine called as Java Virtual Machine, which sits between the program and the actual operating system. A Java program once compiled doesn’t get compiled into machine instructions. When we run a Java programmer, Interpreter sitting in JVM does this parsing. As the parsing happens at runtime we can actually run a Compiled Java Program on any operating system. While for other languages like C/C++ we need to recompile the program on the operating system it wants to run on.

Main Components

On a top level Java has many components like JVM, JRE, library, tools, JDK, Garbage Collection, Class Loader etc. But to understand it better, lets first look at the most important components of Java.

When we actually download Java we have two options. Either to download Java Development Kit (JDK) or to download Java Runtime Environment (JRE). JDK will be required for writing and compiling the Java Applications and JRE is required to run the Java Programs. Typically, the deployment environments like production has JRE installed on it.

To learn more, please read What is JVM, JDK and JRE.

Java Release History

Version Release Date
15 September 2020
14 March 2020
13 September 2019
12 March 2019
11 September 2018
10 March 2018
9 September 2017
8 March 2014
7 July 2011
6 December 2006
5 September 2004
1.4 February 2002
1.3 May 2000
1.2 December 1998
1.1 February 1997
1.0 January 1996
Java (Beta) 1995

Summary

In this theoretical post we had a brief about Java Programming Language. We have covered a brief history of Java, the features and why Java is so popular programming language. We have learnt that Java is an Object Oriented Programming Language and Java’s one of the most important characteristic is Write Once, Run Anywhere (WORA).

In the upcoming articles we will continue diving deeper into this lovely language.