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.
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.
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.
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.
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.
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.
- Java Virtual Machine (JVM)
- Java Runtime Environment (JRE)
- Java Development Kit (JDK)
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
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.