Java Tutorials
Java Variables and Data Types with EXAMPLE
What is a Variable in Java? Variable in Java is a data container that stores the data values...
Java is a general-purpose, class-based, object-oriented programming language designed for having lesser implementation dependencies. It is a computing platform for application development. Java is fast, secure, and reliable, therefore. It is widely used for developing Java applications in laptops, data centers, game consoles, scientific supercomputers, cell phones, etc.
Java Platform is a collection of programs that help programmers to develop and run Java programming applications efficiently. It includes an execution engine, a compiler, and a set of libraries in it. It is a set of computer software and specifications. James Gosling developed the Java platform at Sun Microsystems, and the Oracle Corporation later acquired it.
In this Java tutorial, you will learn-
This video introduces the Java platform, and explains why Java is a platform as well as a programming language.
Click here if the video is not accessible
Java is a multi-platform, object-oriented, and network-centric language. It is among the most used programming language. Java is also used as a computing platform.
It is considered as one of the fast, secure, and reliable programming languages preferred by most organizations to build their projects.
Here are some important Java applications:
Here are important landmarks from the history of the Java language:
Here are a brief history of all the Java versions with its release date.
Java Versions | Release Date |
JDK Alpha and Beta | 1995 |
JDK 1.0 | 23rd Jan 1996 |
JDK 1.1 | 19th Feb 1997 |
J2SE 1.2 | 8th Dec 1998 |
J2SE 1.3 | 8th May 2000 |
J2SE 1.4 | 6th Feb 2002 |
J2SE 5.0 | 30th Sep 2004 |
Java SE 6 | 11th Dec 2006 |
Java SE 7 | 28th July 2011 |
Java SE 8 | 18th Mar 2014 |
Java SE 9 | 21st Sep 2017 |
Java SE 10 | 20th Mar 2018 |
JAVA SE 11 | 25th Sep 2018 |
JAVA SE 12 | 19th Mar 2019 |
JAVA SE 13 | 17th Sep 2019 |
JAVA SE 14 | 17th Mar 2020 |
JAVA SE 15 | 15th Sep 2020 (latest Java Version) |
Here are some important Java features:
A Java Programmer writes a program in a human-readable language called Source Code. Therefore, the CPU or Chips never understand the source code written in any programming language.
These computers or chips understand only one thing, which is called machine language or code. These machine codes run at the CPU level. Therefore, it would be different machine codes for other models of CPU.
However, you need to worry about the machine code, as programming is all about the source code. The machine understands this source code and translates them into machine understandable code, which is an executable code.
All these functionalities happen inside the following 3 Java platform components:
JDK is a software development environment used for making applets and Java applications. The full form of JDK is Java Development Kit. Java developers can use it on Windows, macOS, Solaris, and Linux. JDK helps them to code and run Java programs. It is possible to install more than one JDK version on the same computer.
Here are the main reasons for using JDK:
Java Virtual Machine (JVM) is an engine that provides a runtime environment to drive the Java Code or applications. It converts Java bytecode into machine language. JVM is a part of the Java Run Environment (JRE). In other programming languages, the compiler produces machine code for a particular system. However, the Java compiler produces code for a Virtual Machine known as Java Virtual Machine.
Here are the important reasons of using JVM:
JRE is a piece of software that is designed to run other software. It contains the class libraries, loader class, and JVM. In simple terms, if you want to run a Java program, you need JRE. If you are not a programmer, you don't need to install JDK, but just JRE to run Java programs.
Here are the main reasons of using JRE:
There are four different types of Java programing language platforms:
1. Java Platform, Standard Edition (Java SE): Java SE's API offers the Java programming language's core functionality. It defines all the basis of type and object to high-level classes. It is used for networking, security, database access, graphical user interface (GUI) development, and XML parsing.
2. Java Platform, Enterprise Edition (Java EE): The Java EE platform offers an API and runtime environment for developing and running highly scalable, large-scale, multi-tiered, reliable, and secure network applications.
3. Java Programming Language Platform, Micro Edition (Java ME): The Java ME platform offers an API and a small-footprint virtual machine running Java programming language applications on small devices, like mobile phones.
4. Java FX: JavaFX is a platform for developing rich internet applications using a lightweight user-interface API. It user hardware-accelerated graphics and media engines that help Java take advantage of higher-performance clients and a modern look-and-feel and high-level APIs for connecting to networked data sources.
To understand Java programming language, we need to understand some basic concept of how a computer program can run a command and execute the action.
A computer is an electronic device capable of performing computations. We all know that it is composed of a monitor, keyboard, mouse, and memory to store information. But the most important component of the computer is a PROCESSOR. This does all thinking of computer, but the question is how the computer does this thinking? How does it understand the text, images, videos, etc.?
The computer is an electronic device, and it can only understand electronic signals or binary signals. For example, the 5-volt electronic signal may represent binary number 1, while 0 volts may represent binary number 0. So your PC is continuously bombarded with these signals.
Eight bits of such signals are grouped together to interpret Text, numerical, and symbols.
For example, the # symbol is identified by the computer as 10101010. Similarly, the pattern for adding a function is represented by 10000011.
This is known as 8-bit computing. Current day processor is capable of decoding 64-bit time. But what is the relation of this concept with the programming language JAVA? Let understand these as an example.
Suppose if you want to tell the computer to add two numbers (1+2) represented by some binary numbers (10000011), how are you going to tell this to your computer? Yes, we are going to use assembly language to get our code executed.
"Assembly Language is the most elementary form of software development languages."
We are going to give the command to a computer in this format, as shown below. Your code to add two numbers in this language would be in this order.
But how are we going to do this? Back in the 1950s, when computers were huge and consumed a great deal of power, you would convert your assembly code into corresponding machine code to 1 and 0's using mapping sheets. Later, this code will be punched into the machine cards and feed to the computer. The computer will read these codes and execute the program. This would be a long process then until ASSEMBLER came to help.
With the advancement in technology, i/o devices were invented. You could directly type your program into the PC using ASSEMBLER. It converts it into the corresponding machine code (110001..) and feeds it to your processor. Coming back to our example addition of (1+2), the assembler will convert this code into machine code and output.
That apart, you will also have to make calls to create Operating System provided functions to display the code's output.
But alone the assembler is not involved in this process; it also requires the compiler to compile the long code into a small chunk of codes. With the advancement in software development languages, this entire assembly code could shrink into just one line print f 1+2 A with the software called COMPILER. It is used to convert your c language code into assembly code. The assembler converts it into corresponding machine code. This machine code will be transmitted to the processor. The most common processor used in PC or Computers are the Intel processor.
Though present-day compilers come bundled with assembler can directly convert your higher language code into machine code.
Now, suppose the Windows operating system runs on this Intel processor, a combination of Operating System plus the processor is called the PLATFORM. The most common platform in the world is Windows, and Intel is called the Wintel Platform. The other popular platforms are AMD and Linux, Power PC, and Mac OS X.
Now, with a change in processor, the assembly instructions will also change. For example:
And, with a change in Operating System, OS-level calls' level and nature' will also change.
As a developer, I want my software program to work on all platforms to maximize my revenues. So I would have to buy separate compilers that convert my print f command into the native machine code.
But compilers come expensive, and there is a chance of compatibility issues. So buying and installing a separate compiler for different OS and processor is not feasible. So, what can be an alternative solution? Enter Java language.
By using Java Virtual Machine, this problem can be solved. But how it works on different processors and O.S. Let's understand this process step by step.
Step 1) The code to display the addition of two numbers is System.out.println(1+2), and saved as a .java file.
Step 2) Using the java compiler the code is converted into an intermediate code called the bytecode. The output is a .class file.
Step 3) This code is not understood by any platform, but only a virtual platform called the Java Virtual Machine.
Step 4) This Virtual Machine resides in the RAM of your operating system. When the Virtual Machine is fed with this bytecode, it identifies the platform it is working on and converts the bytecode into the native machine code.
While working on your PC or browsing the web, whenever you see either of these icons, be assured the java virtual machine is loaded into your RAM. But what makes Java lucrative is that code, once compiled, can run not only on all PC platforms but also on mobiles or other electronic gadgets supporting Java.
Hence,
"Java is a programming language as well as a Platform"
Like the C compiler, the Java compiler does not produce native executable code for a particular machine. Instead, Java produces a unique format called bytecode. It executes according to the rules laid out in the virtual machine specification. Therefore, Java is a platform-independent language.
Bytecode is understandable to any JVM installed on any OS. In short, the java source code can run on all operating systems.
Summary:
What is a Variable in Java? Variable in Java is a data container that stores the data values...
What is Comparable in Java? Comparable in Java is an object to compare itself with another object....
What is Inheritance? Inheritance is a mechanism in which one class acquires the property of...
What is JDK? JDK is a software development environment used for making applets and Java...
What is Constructor in Java? CONSTRUCTOR is a special method that is used to initialize a newly...
JavaScript is an open-source and most popular client-side scripting language supported by all...