The Legendary JAVA

Ricky Rinaldy
12 min readSep 18, 2023

Java Programming Language

Section 0: Introduction

What is Java Programming?

Java is a programming language that James Gosling developed at Sun Microsystems_Inc in the year 1995, which later on was taken into possession by the Oracle Corporation in 2009.

  • We can call it a high-level (makes the development of programs easy and much more user-friendly) programming language which makes it very convenient for us to write, compile and debug Java programs.
  • Java is a class-based object-oriented programming language that implements the principle of write once code anywhere.
  • Since Java applications are compiled to byte-code, they can run on any JVM-supported machine.
  • Java codes are very similar to C/C++, which makes them easier to understand.

Why Java Programming Language is Called JAVA?

Java is the name of a beautiful island in Indonesia. It is also said that the first coffee was named right here after java coffee. The name was chosen by James Gosling during the daytime when he was enjoying a cup of coffee near his office. Java was initially called by the name: OAK.

However, in the wake of the Oak Technologies, the team had officially decided to rename it. The options they considered were Silk, Revolutionary, Dynamic, DNA, and Jolt. Even though Silk was further selected, they decided to go along with Java as it was unique, and a lot of people preferred it.

Why Use Java?

Java is a high-level language and should be studied if you want to know the basics of programming. Why there is a need to learn the language.

1) Object-Oriented

2) Portable

3) Simple

4) Secure

5) Robust

6) Platform Independent

7) Architecture neutral

Section 1: Java Prospects

Java Technology

  • Java Standart Edition: The Most Widely used, because it’s used for Websites & Mobile Apps
  • Java Enterprise Edition: More Focuses on Enterprise Apps
  • Java Micro Edition: Since Android has appeared, no one has used it

Java Version

Since Java 10, Java has released its versions on a short-term basis every 6 months. And Java also released its long-term version (LTS).

Java has always consistently been the most popular programming language

Java Programming used most

  • Backend: Many large companies currently use Java as their backend applications, such as Twitter(X), Netflix, Spotify, Amazon, Alibaba, Blibli, and others.
  • Big Data: Big data technologies that are currently popular are mostly Java technologies, such as Apache Hadoop, ElasticSearch, Apache Cassandra, Apache Spark, Apache Kafka, etc.
  • Android: on Android, we can use Java and Kotlin to create applications.

Section 2: Java Terminology

There are some Java terms that we need to understand. So let’s have a brief understanding of the Java terminology.

Java Development Kit (JDK)

Java Development Kit is a full-time kit that has a compiler, Java Runtime Environment(JRE), Debuggers, and Java documents included in it. For further execution in Java, we need to have JDK installed on our computers to further lead to the creation, compilation, and running of the Java program.

Here, as we use JDK, we need an environment to run the programs. We use JRE Java Runtime Environment, which provides the least requirements to execute the Java program. It provides the JVM, Core classes, and supporting files.

Java Run-time Environment (JRE)

JDK includes JRE, which, in turn, after installation, allows the Java program to run. But we still can’t compile it. It has a browser, the applet supports, and a few plugins included in it. So, to run a Java program on your respective computers, you need JRE.

JRE is made up of multiple elements altogether, and they are:

  • Java virtual machine (JVM)
  • Java class libraries
  • Java class loader

When our software tends to execute a particular program, it requires some environment to run in. Usually, it’s any operating system, for example, Unix, Linux, Microsoft Windows, or macOS. Here JRE acts as a translater and facilitator between the Java program and the operating system.

Java Virtual Machine (JVM)

This generally is referred to as JVM and contains three phases that we have to follow. It is a very important part not only of JDK but also JRE as it is inbuilt in both of the places. When you run a program using the JRE and JDK, it also goes to the JVM as it is required to run the Java program and interprets the program. The phases are as follows:

Compile the Code: The Java Development Kit(JDK) provides us with the JAVAC compiler to get through this step. We basically require the JDK to convert our source code into a specific format (compiled code) that can be easily interpreted by the Java Runtime Environment(JRE).

Run the Code: JVM runs the bytecode provided by the compiler. Since Java is a platform-independent language, the compiled code produced by the JAVAC compiler is converted to machine code using platform-specific JVMs. Different platforms have different JVMs. JVMs convert the bytecode into platform-specific machine code.

How this bytecode is developed, making it easy for us to execute our programs.

Bytecode in the Development Process

The source code provided to the JAVAC compiler that is present in JDK gets compiled into a bytecode that the JVM can execute. It gets saved as a .class file by the compiler itself. We can also view this bytecode using a disassembler like javap.

Garbage Collector

Within Java, the programmers cannot delete the objects. Hence, to delete or recollect a memory, JVM has a Garbage Collector. These Garbage Collectors can recollect those objects which have not been referenced. Using this Java makes the life of a programmer very convenient by managing the memory. Despite this, programmers should be aware of what they are writing in their codes or if they are using objects that have already been used for longer. This is because this collector can’t restore the memory of objects that are referenced. Garbage collection here is an automatic process.

Class Path

Classpath is a particular file path where both the Java runtime and Java compiler look for .class files to appear. Although by default, the Java Development Kit provides us with quite a few libraries. Here you can also include an external set of libraries, but they should be added to the classpath beforehand.

Section 3: Java Main Feature

This section will explain the features of the Java programming language.

Platform Independent

First and foremost, the compiler converts the source code to its bytecode, and later on, JVM executes the bytecode generated by its compiler. Further, this bytecode can be run on any other platform, for example, Windows, Linux, or macOS. This means that we can compile a program on Windows and run it on Linux using Linux’s JVM.

Every Operating System has different sets of JVM. These different JVMs generate different platform-specific machine code from the same bytecode. Hence, the output appearing on all the Operating systems will be the same after the execution of our source code. And, we call it a Platform Independent language.

Object-Oriented Programming Language

Object Oriented Programming organizes the software design and logic around classes, objects, and data rather than procedures or functions. Object Oriented Programming uses real-world concepts to implement the application code and keep data security and integrity at the center of design.

Let’s understand this with the help of a real-life example:

We all know that under the Class of Car, we have many options like Alto, WaganR, Santro, etc. In this manner:

  • Each Car object has its specific Model, Colour, Engine power, Top Speed, Year of Manufacture, etc., which altogether are called the properties of the Car Class
  • The functions performed by it, like Start, Stop, Move, etc., are the methods of this Car Class.

No memory is allocated on the creation of a class, but we allocate memory when the object is created, which in our case is a new car object.

The four basic principles in Object Oriented Programming:

  • Inheritance: Inheritance can be defined as an object acquiring all the behaviors and properties of a parent object. It makes our code reusable. Runtime polymorphism can be achieved using inheritance.

So here, the voices of everyone, including the animals and the humans, are inherited by their parents; the dog barks like a dog, and the human speaks like his parents. Hence, we can see a real-life example of inheritance.

  • Polymorphism:

When we perform a single task in multiple ways, it can be defined as polymorphism. In Java, programming language method overriding and method overloading is used to attain polymorphism.

Overloading: When multiple methods in the same class have the same names but different parameters.

Overriding: when the method name and the parameters are the same in the child class and the superclass, we call it overriding.

  • Abstraction

Abstraction is the concept of hiding internal implementation details and exposing only the required functionalities to the end users.

In Java programming language, the interface and abstract class are used to attain abstraction.

Example: We all visit the ATM machine for withdrawing cash and several other things as well, but we never get to know what happens internally inside the machine when we insert our ATM card for any operation. This can be seen as abstraction in real life.

  • Encapsulation

When data is bonded or wrapped together into one single unit, we can call it encapsulation. All the data and methods operating on the data are enclosed in the same unit.

In the Java programming language, the Java class is a major example of encapsulation.

JavaBean is noticed to be fully encapsulated, and this is because all the data members are observed to be private here.

The way this capsule encloses all the contents of the medicine in a similar way when we wrap up data members and methods inside a class, we can term it to be encapsulation.

Simple

Java is generated in a very convenient manner to be able to understand easily. If you understand the basic OOPs, it is easy to master the art. Moreover, it does not contain any complex features like pointers, multiple inheritances, operator overloading, etc.

Robust Language

So the literal meaning of robust can be easily understood as reliable. Java has been developed in such a way that it checks for errors pretty early, which results in errors being detected by the Java compiler, which is pretty difficult when it comes to other programming languages.

Secure

Java turns out to be very secure, and that is because we do not have access to pointers here. Due to the lack of pointers, we are unable to get access to outbound arrays, and this makes it impossible for the flaws like buffer overflow or stack corruption to occur.

Portable

Having no implementations and being independent of the aspects of specification make Java Portable. It can be run on any platform as it is completely platform-independent like Windows Linux macOS. This means that if you compile a program on Linux, you can run it on Windows and the other way round.

Sandbox Execution

Java programs run in a separate space that allows user to execute their applications without affecting the underlying system with the help of a bytecode verifier. Bytecode verifier also provides additional security as its role is to check the code for any violation of access.

Architecture neutral WORA(Write Once Run Anywhere)

This can be seen as one of the best features of Java as it states that a Java program can be easily executed on any processor irrespective of its vendor and architecture. Java application generates a .class file, which corresponds to our applications but contains code in binary format. It provides architecture-neutral ease as bytecode is not dependent on any machine architecture.

So features of the Java programming language were pretty interesting, and now it’s time to see where we can use them. So, let’s see some applications of the Java programming language.

Section 4: Applications of Java

Applications of Java Programming Language

As Java kept getting better and more advanced, it became pretty popular, building several configurations capable of suiting multiple platforms.

List of applications of the java programming language. Let’s have a look:

Multithreaded

Using this feature, it becomes easy for us to write programs that are able enough to perform multiple tasks simultaneously. This comes in handy to developers when they make interactive applications that can run smoothly.

High Performance

The Java architecture is designed in such a way that it reduces the overhead when we run an application, and at some times, it uses the JIT(Java In Time) compiler where the compiler easily compiles the code on-demand basics where it only compiles the methods that we call which makes the applications execute faster.

Distributed

When we use the Java programming language, we get able enough to create distributed applications. RMI(Remote Method Invocation) and EJB(Enterprise Java Beans) help us to create distributed applications.

Let’s understand in simple words: The language can easily be distributed onto more than one system which is connected to each other through an internet connection. Objects on one JVM can be easily used to execute the procedures on a remote JVM.

Dynamic

Java can be easily considered to be more dynamic than the C and C++ programming languages. This can be said by looking at its ability to adapt to an evolving environment. The programs are capable of carrying an extensive amount of run-time information, and this information can be used in the verification of objects during the run-time.

Section 5: Basic Syntax in Java

Let’s have a deeper understanding of how a Java program works.

Output:

Welcome Back, Ricky R

Explanation

1. //

This symbol in the code represents Comments in Java. The purpose of comments in a program or code is to explain the program. When you compile a program, the compiler ignores the comment lines and are not executed. There are two types of comments single-line and multi-line. Let’s look at the syntax of single-line and multi-line comments.

// I am a single-line comment.
/* I am a multi-line comment. */

2. import java.io.

Import is a keyword that includes the class we use in the code. This is used to import all the classes of the io package. Java’s io package includes a set of input and output streams used to read or write files and input or output.

3. public class

The data and methods that need to be used in the program are included in the class. Methods define the behavior of the class.

4. public static

Static methods do not require objects to get called. They can be executed using the dot operator with the class name.

5. void

Does not return any value. It’s an empty void.

6. main()

Name of the method. Entry point method where JVM runs the program.

7. (String[ ] args)

These are used as command-line arguments and are passed as strings.

8. System.out.println

This command prints the contents provided within the print statement.

Final Section: Conclusion

1. OOP

Java can be a class-based, object-oriented programming language designed to minimize implementation dependencies as much as possible.

2. High-Level Language

Java is an easy-to-understand high-level language with syntax similar to C/C++.

3. WORA (Write Once Run Anywhere)

Java is platform-independent, and this makes it better than other programming languages. Java implements the write once run anywhere principle.

4. Adaptive

Java is a portable, simple, secure, and powerful programming language suitable for large code bases.

5. Machine Code

JDK is a development environment for building applications, applets, and components using the Java programming language.

JDK includes useful tools for developing and testing programs written in the Java programming language and running on the Java platform.

JRE consists of several elements at once, namely: Java virtual machine (JVM), Java class library, and Java class loader.

Both JDK and JRE require a JVM, which is specifically responsible for converting bytecode into machine-specific code.

JVM is platform-dependent; it performs various tasks, such as memory management. Additionally, the JVM can run programs that have been converted to Java bytecode from other programming languages.

Classpath is a specific file path where the Java runtime and Java compiler look for .class files to appear.

6. High Performance

Java is used in Multithreaded, distributed, dynamic and high-performance applications.

“Thank You For Reading This.

--

--