When a Java program is compiled , then the Java program does not convert completely to Machine Language but converts to an Intermediate Language, called Java Bytecodes . These codes are platform independent, so they can be run on any operating system and any processor. Compilation of a Java program occurs only once, but each time a Java program is run, there is an Interpretation of that program each time . We can understand this by the following picture-
We can consider Java Bytecodes as Machine Codes for Java Virtual Machine (Java VM) . Every Java Interpreter, whether it is Java Development Tool or a Browser that runs Java Applets, is the only implementation of Java Virtual Machine. Java Virtual Machine can also be implemented in hardware, the result of which is today’s Mobile System Software .
Java Bytecodes gives us this facility to compile Java’s program once and run anywhere. We can compile a Java program on any computer that has a Java Compiler. Bytecodes of that Java program can then be run on any computer that has a Java VM . For example, the same Java program can be executed on different platforms like Windows, OS / 2 MacOS NT, Macintosh etc.
A platform is a software or hardware environment in which a program runs. The Java Platform is different from many other platforms. Java Platform is a Software Platform that runs at the top of all other Hardware Based Platform. Most other platforms are Combination of Hardware and Operating System. Java Platform has two components.
- The first is the Java Virtual Machine (Java VM) that we have come to know about. It is the base or base of the Java Platform and rests on various Hardware Base Platforms.
- Another is the Java Application Programming Interface (Java API), which we will now know about.
The Java API is a large collection of Ready Made Software Components that provide programmers with many useful capabilities such as GUI (Graphical User Interface). Java APIs have been grouped as Libraries of Related Components. The groups of these various related components are called Packages . Which is somewhat similar to C / C ++’s Header Files , but C’s Header File is a collection of functions in a way, whereas Java’s Package is a collection of Classes. We can show a Java program as follows:
When a Java program is executed on a computer, there are layers of Java API and Java Virtual Machine between the Java Program and the Hardware Based Platform that separate the Java Program from the Hardware Dependencies. That is, because of these two, no program of Java is dependent on the hardware of any computer. Java’s program as a Platform Independent Environment is somewhat slower than other Native Codes Programs. But still good compilers, well-tuned Interpreters with Java and Bytecodes Compilers can bring Java’s performance around the performance of Native Code and that too with all the features of Java.
The most well-known form of Java programs, if any, is that of Java Applets . An Applet is also a Java program but its feature is that it runs in any Java Enabled Browser such as Internet Explorer, Netscape Navigator, Google Chrome, Opera, FireFox etc., it cannot run independently. While Java Application can be Standalone Run. Applets are similar to Application.
It is also not that Java can be used only for writing Web Pages Applications. Rather Java is also a Powerful Software Platform and General Purpose, High Level Programming Language . Examples of Java’s most common application programs are Servers that serve to provide various clients to a network . Web Servers, Proxy Servers, Mail Servers, Print Servers and Boot Servers are various examples of Java applications. Servlets are similar to Applets but run in Java Servers and Configuring or Tailoring Java Server instead of Run in a Browser .
A question may arise as to how the Java API supports all these types of programs. The answer is that it supports all these types of programs through a package of software components that have different types of functionalities. The Core API is an API that is fully implemented in every Java platform. The Core API provides us with the following features –
Provides the facility to handle objects such as objects, strings, threads, numbers, input and output, data structures, system properties, date and time.
Java provides various components for creating applets.
Provides URLs, TCP and UDP sockets and IP addresses to facilitate networking.
It gives us such a facility that we can write programs that can run equally in the whole world.
This gives us both low-level and high-level protection. It also provides facilities for electronic signatures, public / private key management, access control and certificates.
It provides us with components such as JavaBeans that can be plugged into a pre-built Component Architecture such as Microsoft’s OLE / COM / Active-X architecture, OpenDoc and Netscape’s Live Connect.
It allows us to communicate with other simple devices through Remote Method Invocation (RMI), which is also being used today in Mobile Technology.
Java Database Connectivity (JDBC):
It allows us to connect to Relational databases and access them.
Java not only has Core APIs but also some Standard Extensions. These also define APIs for Standard Extensions 3D, Servers, Collaboration, Telephony, Speech, Animation and many other things.