Java - A Programming Language
Table of contents
We will learn Java programming fundamentals in this first blog.
What is Java?
Java is OOP (object-oriented programming) language. It is a high-level language because it is closer to human-readable language. It is designed by James Gosling at Sun Microsystems. It was introduced on 23rd May 1995. It is a platform-independent language. You can code on one platform (e.g. Windows) and run it on another platform (e.g. Linux). It means compiled code can run on all platforms that support Java without recompilation. Its motto is WORA (Write Once Run Anywhere). It is a statically typed language. It means you require to define a specific type for the variable explicitly.
There were five primary goals in the creation of the Java language:
- It must be simple, object-oriented, and familiar
- It must be robust and secure
- It must be architecture-neutral and portable
- It must execute with high performance
- It must be interpreted, threaded, and dynamic
There are four editions of Java.
- Java Card - for smart cards
- Java ME (Java Platform, Micro Edition) - It is targeting an environment with limited resources. e.g. Mobile phone, TV setup box, etc
- Java SE (Java Platform, Standard Edition) - It is targeting workstation environments. You can implement and run code using this edition.
- Java EE (Java Platform, Enterprise Edition) - It is targeting large distributed enterprises or Internet environments. It is used for computing environments and web services. It is an extension of Java SE. It was renamed Jakarta EE in 2019. Jakarta EE 8 is the first version after renaming from Java EE. Jakarta EE 8 is fully compatible with Java EE 8.
There are three components to develop Java programs:
- JVM
- JRE
- JDK
They are interrelated to develop and run Java programs.
What is JVM?
JVM stands for Java Virtual Machine. It is not a physical machine. It enables computer to run Java programs as well as programs written in other languages that are also compiled into Java bytecode. Java bytecode is machine level code that executes in hardware level and it is not human-readable code.
JVM performs the given below operations:
- Loads code
- Verifies code
- Execute code
- Provides runtime environment
What is JRE?
JRE stands for Java Runtime Environment. It provides class libraries and resources to run Java programs. It combines Java code and other resources to run Java programs. JRE consists JVM. JRE is the part of JDK. It consists JIT (Just-In-Time) compiler.
It takes the given below steps at runtime:
- Class Loader
- Byte Code Verifier
- Interpreter
What is JDK?
JDK stands for Java Development Kit. It consists JRE and other development tools. It uses to develop Java programs. It physically exists. It consists javac (Java Compiler). We require to code in .java file. javac converts .java file to .class file (bytecode). If a Java program has more than one class, in such cases after compiling the source file, we get the same number of .class files as the number of classes a Java program has.
Oracle maintains its proprietary JDK with a subscription. You require a subscription to use JDK 8+ for commercial use. It is available for personal use without a subscription. JDK 17 is available under NFTC (No-Fee Terms and Conditions). You will get security patch updates and support if you have subscription. Oracle recommends JDK 8 and onward versions to develop Java programs.
OpenJDK is FOSS (Free and Open-Source Software). It's all versions available for free to use. You will get all updates with OpenJDK. Other organizations also offer their version of JDK builds. e.g. Microsoft, IBM, Red Hat, etc.
Oracle JDK is much better than OpenJDK in terms of performance. OpenJDK has more community support than Oracle JDK. You can check its version history. We require to use LTS (Long-Term Support) versions for production.
I will update this blog for future update of Java. We will perform installation steps for Java in next blog of this series.