for 2022 Important Informetion of java, Basic important of java .
What is java ? , Class lodder , Execution engine ,
J D K , J R E , J V M .
Why java comes to the market?
Java programming language mainly designed to overcome the disadvantages of c and C++ and to develop internet applications by achieving platform independence.
What is exactly java?
Java is a technology that provides two things
- Programming language(JSE/core java3)
- Platform (JVM)
By using the language we can develop java applications and also provides a runtime environment (JVM) where we execute java programs.
As we know java comes in three different editions which allows us to develop three different types of applications, the three different editions are
- JSE (java standard edition)
- JEE (java enterprise edition)
- JME (java micro edition)
These three different types of editions allow us to develop three different types of applications. They are as follows
- Standalone/Desktop application
- Enterprise / Distributed / Internet application
- Device application
What is a standalone application?
An application installed in one system that can be executed from the same system but can’t be executed from another system is called a standalone application. The application developed for the context of one client is called a standalone application. JSE is used for developing standalone applications.
What is an enterprise application?
An application whose resources are shared among multiple clients is called distributed/ enterprise application. All internet applications are called distributed applications. These applications are present in the server system. JEE is used for developing internet applications.
There are two types of internet applications, such as
- Web supportive application
- Web application
Web supportive application
An application that resides in the server system and that is downloaded and executed on the client computer by network call is called a web supportive application.
Web application
An application that resides in the server system and that is executed directly in the server system via network call and send the response back to the client system is called a web application
What is the device application?
JME means java mobile/micro edition. JME is used for developing device applications, such as mobile games tablets. JME is used for developing software for consumer electronics devices means embedded systems like mobile, it is popular for developing mobile gaming applications, a fully automated washing machine, robot
Important Informetion of java, Basic important of java .
What is a platform?
A platform is an environment where we execute something. A platform is a hardware or software environment where a program runs. For example, a computer platform is( OS+ hardware devices)
What is Platform Dependent?
The programs or applications complied on one platform (operating system) can be executed on the same type of operating systems but cannot be executed on other types of operating systems is called platform-dependent applications.
The programming languages which are used to develop such type of applications are called platform dependent programming language. C, C++ is called a platform-dependent programming language, because when C, C++ programs have complied, C, C++ compiler generates machine codes that are specific to the operating system.
Drawbacks: We need to develop the same application multiple times which increases the development cost and time.
Solution: Need to develop platform Independent application.
Platform Independent:
If the applications complied code is able to run on different types of OS irrespective of the OS where it is compiled then such applications are called platform-independent applications.
The programming language which is used for developing such type of applications known as the platform-independent programming language.
Java is a platform-independent programming language because java program compiled code can execute (run) on any OS.
In this case, when the source code is compiled, the compiler generates intermediate code (byte code) rather than machine code, which is not specific to any OS. The intermediate code can be carried and executed on any machine provided software called JVM which is responsible for converting intermediate code into machine code
What is Byte Code?
Java programs compiled code is called byte code. When the java code is compiled java compiler (javac) generates byte code (intermediate code).
- Byte code is an intermediate language (IL) code.
- Byte code is a virtual machine code.
- Byte code is a platform-independent code.
- Byte code is the collections of mnemonics (MOVE, LOAD, ADD ETC), these byte codes are only understood by JVM.
- Every byte code occupies 1 byte.
What is the difference between byte code and machine code in Java?
Java Application Development Lifecycle
Java Application Development Lifecycle:
There are three core technology packages used in Java Programming: JDK, JVM, and JRE
JDK (Java Development Kit):
The JDK (Java Development Kit) allows developers to create Java applications and applets that can be executed and run by the JVM and JRE. The JDK is a software package you download in order to create Java-based applications. The JDK is an implementation of the Java platform specification, including compiler and class libraries.
The important features of JDK are:
- It enables you to handle multiple extensions in a single catch block.
- JDK includes all features that JRE has.
- It contains development tools such as a compiler, debugger, etc.
- JDK provides the environment to develop and execute Java source code.
- It can be installed on Windows, Unix, and Mac operating systems.
JVM (Java Virtual Machine) :
- JVM (Java Virtual Machine) is an abstract machine. It is called a virtual machine because it doesn’t physically exist. It is a specification that provides a runtime environment in which Java bytecode can be executed. It can also run those programs which are written in other languages and compiled to Java bytecode. It converts Java bytecode into machine language. JVM is a part of the Java Run Environment (JRE). It cannot be separately downloaded and installed. To install JVM, you need to install JRE.
- The important features of JVM are :
- It enables you to run applications in a cloud environment or in your device.
- Java Virtual Machine converts byte code to machine-specific code.
- It provides basic java functions like memory management, security, garbage collection, and more.
- JVM runs the program by using libraries and files given by the Java Runtime Environment.
- JDK and JRE both contain Java Virtual Machine.
- It can execute the java program line by line hence it is also called an interpreter.
- JVM is easily customizable for example, you can allocate minimum and maximum memory to it.
- It is independent of hardware and the operating system. So, you can write a java program once and run it anywhere.
Java Architecture - Java Architecture is a collection of components, i.e., JVM, JRE, and JDK. It integrates the process of interpretation and compilation. It defines all the processes involved in creating a Java program. Java Architecture explains each and every step of how a program is compiled and executed.
- Java Architecture can be explained by using the following steps:
- There is a process of compilation and interpretation in Java.
- Java compiler converts the Java code into byte code.
- After that, the JVM converts the byte code into machine code.
- The machine code is then executed by the machine.
Components of Java Architecture
The Java architecture includes the three main components:
- Java Virtual Machine (JVM)
- Java Runtime Environment (JRE)
- Java Development Kit (JDK)
JVM(Java Virtual Machine) acts as a run-time engine to run Java applications. JVM is the one that actually calls the main method present in a java code. JVM is a part of JRE(Java Runtime Environment).
Java applications are called WORA (Write Once Run Anywhere). This means a programmer can develop Java code on one system and can expect it to run on any other Java-enabled system without any adjustment. This is all possible because of JVM
Class Loader Subsystem
It is mainly responsible for three activities.
Loading
Linking
Initialization
Loading:
The Class loader reads the “.class” file, generate the corresponding binary data and save it in the method area. For each “.class” file, JVM stores the following information in the method area.
The fully qualified name of the loaded class and its immediate parent class.
Whether the “.class” file is related to Class or Interface or Enum.
Modifier, Variables and Method information etc.
After loading the “.class” file, JVM creates an object of type Class to represent this file in the heap memory. Please note that this object is of type Class predefined in java.lang package. These Class object can be used by the programmer for getting class level information
For every loaded “.class” file, only one object of the class is created
for 2022 Important Informetion of java, Basic important of java .
Linking:
Performs verification, preparation, and (optionally) resolution.
- Verification: It ensures the correctness of the .class file i.e. it checks whether this file is properly formatted and generated by a valid compiler or not. If verification fails, we get run-time exception java.lang.VerifyError. This activity is done by the component ByteCodeVerifier. Once this activity is completed then the class file is ready for compilation.
- Preparation: JVM allocates memory for class variables and initializing the memory to default values.
- Resolution: It is the process of replacing symbolic references from the type with direct references. It is done by searching into the method area to locate the referenced entity.
- Initialization:
- In this phase, all static variables are assigned with their values defined in the code and static block(if any). This is executed from top to bottom in a class and from parent to child in the class hierarchy.
There are three class loaders
- In this phase, all static variables are assigned with their values defined in the code and static block(if any). This is executed from top to bottom in a class and from parent to child in the class hierarchy.
- Bootstrap class loader:
- Every JVM implementation must have a bootstrap class loader, capable of loading trusted classes. It loads core java API classes present in the “JAVA_HOME/jre/lib/rt.jar” directory. This path is popularly known as the bootstrap path. It is implemented in native languages like C, C++.\
- Extension class loader:
- It is a child of the bootstrap class loader. It loads the classes present in the extensions directories “JAVA_HOME/jre/lib/ext”(Extension path) or any other directory specified by the java.ext.dirs system property. It is implemented in java by the sun.misc.Launcher$ExtClassLoader class.
- System/Application class loader:
- It is a child of the extension class loader. It is responsible to load classes from the application classpath. It internally uses Environment Variable which mapped to java.class.path. It is also implemented in Java by the sun.misc.Launcher$AppClassLoader class.
JVM follows the Delegation-Hierarchy principle to load classes. System class loader delegate load request to extension class loader and extension class loader delegate request to the bootstrap class loader. If a class found in the boot-strap path, the class is loaded otherwise request again transfers to the extension class loader and then to the system class loader. At last, if the system class loader fails to load class, then we get run-time exception java.lang.ClassNotFoundException.
JVM Memory
- Method area: In the method area, all class level information like class name, immediate parent class name, methods and variables information etc. are stored, including static variables. There is only one method area per JVM, and it is a shared resource.
- Heap area: Information of all objects is stored in the heap area. There is also one Heap Area per JVM. It is also a shared resource.
- Stack area: For every thread, JVM creates one run-time stack which is stored here. Every block of this stack is called activation record/stack frame which stores methods calls. All local variables of that method are stored in their corresponding frame. After a thread terminates, its run-time stack will be destroyed by JVM. It is not a shared resource.
- PC Registers: Store address of current execution instruction of a thread. Obviously, each thread has separate PC Registers.
- Native method stacks: For every thread, a separate native stack is created. It stores native method information
Execution Engine
Execution engine executes the “.class” (bytecode). It reads the byte-code line by line, uses data and information present in various memory area and executes instructions. It can be classified into three parts:
Interpreter: It interprets the bytecode line by line and then executes. The disadvantage here is that when one method is called multiple times, every time interpretation is required.
Just-In-Time Compiler(JIT) : It is used to increase the efficiency of an interpreter. It compiles the entire bytecode and changes it to native code so whenever the interpreter sees repeated method calls, JIT provides direct native code for that part so re-interpretation is not required, thus efficiency is improved.
Garbage Collector: It destroys un-referenced objects. For more on Garbage Collector, refer Garbage Collector.
Java Native Interface (JNI) :
It is an interface that interacts with the Native Method Libraries and provides the native libraries(C, C++) required for the execution. It enables JVM to call C/C++ libraries and to be called by C/C++ libraries which may be specific to hardware.
Native Method Libraries :
It is a collection of the Native Libraries(C, C++) which are required by the Execution Engine.
Important Informetion of java, Basic important of java .
What is java ? Important Informetion of java, Basic important of java .
What is java ? Important Informetion of java, Basic important of java .