1. History of Java

When Sun Microsystems announced the birth of the Java language on May 23, 1995, the total number of people using Java at that time was less than 30. Most of the co-founders, including James Gosling, the father of the Java language, probably couldn’t have predicted it. Java will have such a profound impact on the Internet and even our lives in the next two decades.

Currently, Java is available in the following three versions:

  • Java Platform, Enterprise Edition (Java EE: Java Platform Enterprise Edition)

  • Java Platform, Standard Edition (Java SE);

  • Java Platform, Micro Edition (Java ME: Java Platform Micro Edition)

In 2006, SUN announced at the JavaOne conference that it was contributing the Java platform to the open source world under the GNU General Public License (GPL), The release includes Standard, Micro, and Enterprise versions. This is a change of “historic significance”.

2. Language features

The birth of the Java language redefined object-oriented programming (OOP). When the Java language was created, the following goals were set:

  • Easy to learn, and object-oriented;

  • Must be robust and secure;

  • Get rid of platform dependence;

  • High performance execution;

  • It must be explicable, multi-threaded, and dynamic.

2.1 Object-oriented

Object Oriented refers to a programming method. The main idea of object orientation is to design software around the “things” (objects) that we manipulate. The development of computer hardware provides a better soil for the development of software technology. In order to make large-scale software projects easy to manage and reduce the cost of development and maintenance, object-oriented technology emerged as The Times require. In order to understand the birth of object-oriented technology, we will introduce several representative software technologies.

2.1.1 Assembly language

The beginning of software technology was assembly language, which was very close to machine language and could be easily converted into executable code. Programmers who use assembly language must understand the detailed architecture of a computer before they can write programs.

2.1.2 Program language

After assembly language, high-level languages were developed that could be converted from high-level program code to machine instructions using the language’s compiler (such as GCC). This eliminates the need for programmers to delve into the architecture of computer hardware. To improve code reusability and minimize the use of GOTO instructions, procedural techniques were introduced. While it simplifies the creation and maintenance of software flow control, it neglects the organization of data. Debugging and maintaining a program with many global variables becomes a programmer’s nightmare.

2.1.3 Object-oriented language

In object-oriented languages, data is abstractly encapsulated in objects. Data specific to an object can only be accessed through that object. In this way, the program becomes a series of interactions between objects. The Java language is a pure object-oriented language.

2.2 Cross-platform

We may often hear the phrase “write once, run anywhere.” This refers to the cross-platform nature of Java. Let’s first look at how code in C or C ++ runs on different platforms:

In C or C ++, we first compile the source file into a machine code file, and then execute it. In this process, the machine code file must be executed on the platform for which it was compiled (Windows, Linux, Mac OS, etc.), which means that our code must be compiled multiple times if it wants to be executed on multiple platforms. This not only creates tedious development steps for programmers (minor code changes require recompiling the entire program), but also increases the risk of bugs. When code has been compiled into an executable, the executable cannot be changed dynamically, and the code needs to be recompiled to replace the old executable.

Let’s take a look at how Java works:

The idea of Java is that code is compiled into an intermediate language, which is bytecode, and the interpreter is the Java Virtual Machine (JVM). Bytecode files are generic, and the JVM is platform-specific. As shown below:

Every platform requires a JVM, and the JVM is a key prerequisite for executing everywhere, so in Java we only need to generate a bytecode file to ensure that our programs will run on any platform.

2.3 standardized

In Java, a large number of standardized libraries are provided, which ensures that we use a unified interface to control our programs.

2.4 Exception Handling

The old method of exception handling was to make each function return an error code, and the caller would check what it returned, leading to checkmarks of error codes all over the code, making the source code hard to read.

In the new approach to exception handling, functions or methods do not return error codes, but instead throw exceptions. In Java, the catch keyword can be used to catch exceptions that occur within a try block. This way, we don’t need to frequently define error code to handle exceptions, and the code readability is greatly improved.

2.5 Dynamic class loading

In Java, if a class is not needed at execution time, it is not compiled to bytecode. This feature is very common in network programming. When we don’t know what code will be executed, a program can load classes from a file system or a remote server.

2.6 Automatic garbage collection mechanism

In regular languages, such as C and C++, the programmer must ensure that allocated memory is freed. Prevent trouble causing memory leaks.

Memory resources or buffers have specific modes of operation for optimal performance. Once a buffer is full of data, it needs to be cleaned up after its contents are no longer in use. Memory can easily become overloaded if programmers forget to clean up their code. Java uses an automatic garbage collector to manage memory in the object life cycle. The programmer determines when an object is created, and the Java runtime takes care of restoring memory once the object is no longer in use. Once there is no reference to an object, the garbage collector automatically frees unreachable memory.

Automatic garbage collection makes code written in Java more robust, reducing the risk of memory leaks and spills. The only thing programmers need to be aware of is the speed of object creation. If your application creates objects faster than the garbage collector can free them, memory-related problems may result.

3. Java version history

The major releases of Java and their release dates are as follows:

  • JDK 1.0 (January 23, 1996)

  • JDK 1.1 (February 19, 1996)

  • J2SE 1.2 (December 8, 1998)

  • J2SE 1.3 (8 May 2000)

  • J2SE 1.4 (6 February 2002)

  • J2SE 5.0 (September 30, 2004)

  • Java SE 6 (11 December 2006)

  • Java SE 7 (July 28, 2011)

  • Java SE 8 (March 18, 2014)

  • Java SE 9 (September 21, 2017)

  • Java SE 10 (March 20, 2018)

  • Java SE 11 (September 25, 2018)

  • Java SE 12 (19 March 2019)

  • Java SE 13 (17 September 2019)

  • Java SE 14 (17 March 2020)

  • Java SE 15 (15 September 2020)

  • Java SE 16 (March 16, 2021)

4

We’ll go into more detail on how to install Java on different platforms later. Before installing Java, we need to understand two terms, JDK and JRE:

  • JRE: Java Runtime Environment

  • JDK: Java Development Kit

The JDK is a superset of the JRE, which contains all the content of the JRE, as well as tools needed to develop small programs and applications, such as compilers and debuggers.

Simply put, if we want to use the Java language to develop applications, we need to install the JDK on our computers. This tutorial uses the latest version of Java 16.

5. Learn the basics

Learn this tutorial, had better have certain computer basic knowledge, familiar with computer software download, installation, etc. Of course, don’t worry if you don’t have any basic knowledge, this tutorial will try to explain the knowledge in plain English.

6. Summary

In most people’s eyes, the Java language is perfect, but it is not without its flaws. The Java language lacks hardware-specific data types and features such as Pointers to arbitrary addresses or programming methods. While these features can be misused or abused by programmers, they are powerful tools.

In this section, we’ve taken a look at the history and major features of the Java language. So in the next section, we’ll learn how to install Java on your own computer.

Wechat official account