Java Development Kit is responsible to run Java programs. The programs developed in Java are executed in a software environment popularly known as Java Platform Standard Edition or Java SE. Java SE is used for creating and executing Java desktop applications and Server applications.
Java SE uses Java language to create Java Programs. Java is a language developed at Sun Microsystems and used to develop application software. Java is in embedded devices, Java is used to develop mobile phone applications, Java is used to develop server applications, and Java is also used to develop Java applets that can be combined with HYML pages.
Programs written in Java language are translated into byte code using JVM (Java Virtual Machine). To translate the java source code into byte code compilers are used. The grammar of the Java language is inherited from the language C and C++. Java Object-Oriented characteristics are taken from Smalltalk and Objective-C. Memory is managed by Java Virtual Machine using garbage collection techniques.
Java has a platform that is used to create and execute Java language programs. This platform of Java consists of a set of programs such as Java virtual machines, a compiler to execute java programs, and a rich inbuilt library. Java platform supports a large range of hardware platforms and operating systems, this makes java programs to be executed similarly on the wide range of hardware platforms and operating systems.
There exists a different kinds of Java Platform such as Java Card, Java ME, Java SE, and Jakarta EE.
Java Card is used for developing Java Applets. Java Applets are Java language applications and are small in size. These applications are successfully executed on devices that are low in memory.
Java ME is also known as Java Micro Edition. Java ME consists of a rich set of libraries and is used to develop applications that are executed on devices having limited memory size, limited display capacity, and limited power capabilities. A large number of mobile devices, a large set of PDAs, and a large number of set-top box devices use software applications developed on Java ME.
To develop desktop-based applications Java Standard Edition is used. Java Standard Edition is also used to develop server applications and applications that can be used on other similar types of devices.
To develop Application Programming Interfaces (API) is used. Different API is used for different server applications.
Java platform comprises of different programs and these programs contribute to the creation, development, and execution of different Java programs. Java compiler is one such program that is included in the Java platform. Java COmpiler is responsible for converting java source code into java bytecode. Java bytecode is used by Java Virtual Machine ad is known as an intermediate language. Java compiler comes with Java Development Kit also known as JDK. This bytecode generated by the Java compiler is converted into native machine code with the help of the just-in-time compiler. Thus java platform consists of a java compiler, a rich source of a library, and an environment that has the ability to execute bytecode.
The most important component of the Java platform is the java virtual machine. Java Virtual Machine is responsible to execute compiler-generated java bytecode. The bytecode generated by the java compiler is platform-independent.
The execution of the Java program on any machine is possible because the compiler-generated bytecode is converted into an intermediate language. The Just-In-Tine compiler is responsible for converting the compiler-generated bytecode into an intermediate language. Java Virtual Machine replaced interpreter. The code generated by the Java Virtual Machine is not platform-independent.
Java Class Library
Java Class Library is also responsible to execute Java programs, this class library is also available in Operating System but since Java is a platform-independent language the java platform contains these libraries implicitly without relying on the operating system. The Swing library of the Java platform is responsible to draw user interfaces and track and handle events. Java class libraries help programmers to perform tasks related to file handling, basic input-output operations, task-related to string manipulation, etc. The java class library also supports a large setof functions that are used for network communications. To perform network communication java.net library is used and to perform basic input-output java.io is used.
Third-Party Interpreters and Compilers of Java
There exist many compilers and interpreters for specific Java Virtual Machine. These third-party interpreters and compilers support the existing java language. The third-party interpreter and compiler include Beanshell, JRuby, Jython, Rhino, etc.
Java Development Kit
The Java Development Kit is used for Java Software. The Java Development Kit consists of Java Compiler, Java Runtime Environment (JRE), and different tools responsible for the development of the software.
The Java Development Kit consists of the following programming tools:
JDK appletviewer is responsible for the command-line program. appletviewer is used as a tester to test the developed applications before they are finally deployed on the website. The Java applets do not use a web browser though it uses HTML documents but to execute the Java program applet viewers find applet tags and avoids parsing HTML tags. This applet viewer is embedded in JDK.
this is a java compiler and is responsible to convert the java source code into java bytecode. Java compiler comes with JDK. The javac is responsible to check the syntax and semantic of the source code this is done using Java Language Specification. When the syntax and semantic of the java source code are checked then this code is converted into java bytecode. This bytecode adheres to the specification of the Java Virtual Machine. The Java compiler javac is written in Java language.
this is responsible for creating documentation from the comments of java source code. Javadoc is creates documentation using comments of java source code in HTML format. Since the documentation is in HTML it can be linked with other related documents. Some of the integrated development environments of java such as Netbeans and Eclipse creates HTML documentation automatically.
JAR (file format):
JAR is a distribution file that contains a Java class file, metadata, and resource file that contains text, images, etc. The JAR file also contains the manifest file. The JAR file is the form of the ZIP format and has a .jar extension. This is helpful in the deployment of java applications. These are compressed files.
This is in JDK to monitor Java Virtual Machine and applications developed in JAVA that runs on local as well as on remote servers. JConsole generates a report providing analyses on performance and resource consumption of the developed java applications.
JShell is in JDK to evaluate expressions. JShell is also known as Java read-eval-print loop.
VisualVM is used to display information of Java programs at the time when they are being executed on Java Virtual Machine. VisualVM is responsible for displaying information of different Java applications, these applications can be localhost or on the remote host. This tool is available in JDK. VisualVM displays the total amount of memory consumed, all threads that are associated with the java application, manages and maintains memory allocation, manages and maintains dump files related to thread dumps and heap dumps, and core dumps. VisualVM is also responsible for providing recordings of JRF.
JDK is compatible with the Java Runtime Environment and is also known as private runtime. The Java Runtime Environment executes Java programs as well as the programs of other languages that are converted into Java bytecode. The specifications are given a JVM that defines what is required to convert source code into bytecode. These specifications are responsible for making the java program platform independent
The JVM has a class loader that is responsible for loading classes that adhere to the file format of Java. The class loader conducts the loading of binary data and links different classes after verifying the type of the imported class. The class loader is also responsible for memory allocation to used variables and programs instructions. The class loader is also responsible for resolving symbolic references into direct references. The class loader is responsible for initializing class variables with their starting values.
Java Virtual Machine supports two categories of class loader first, bootstrap class loader, and second, user-defined class loader. Each JVM consists of the bootstrap class loader that loads the required classes.
The JVM works with different data types and reference types. The JVM specification provides details of supported data types and reference types. The JVM also maintains a heap to store objects and arrays. The JVM maintains “method arera” which is a memory location where programming instructions, constants, and classes are stored. All the threads of the Java program are also maintained by JVM and JVM uses a call stack to maintain it. Each time a function is called JVM maintain a frame for it and the function execution is completed then its associated frame is deleted.
The JVM has detailed specifications for loading and storing required java components, for Arithmetic operations, for type conversions, for creation of objects and their manipulations, for maintaining stacks, for transferring and branching control, maintains and manage methods, JVM also handles exceptions and maintains and manages concurrency.
JVM is not platform-independent and is different for the different operating systems. The class file Java Virtual machine is Java Byte Code and its associated Symbol Table. The JVM language is JRuby and Jython. All JVM languages are interoperable.
Execution and Compilation of Java Program
Compilation of the java program is a two-step process. The First Java program is executed by the java compiler then it is processed by Java Virtual Machine. The java program is created in a ‘.java’ file.
This ‘.java’ file is processed by the compiler. The java compiler converts the java program source code into machine code, this machine code is also known as Byte code. To generate byte code from source code the java compiler parse the source code. Praising creates an abstract syntax tree. The java compiler then creates Symbol Table. The compiler then annotates all the associated processes after this syntax tree is attributed by checking the type, resolving names, and constant folding. The compiler then checks code reachability and assignments. When this is done Abstract Syntax tree is rewritten. When all this process is done ‘.Class’ files are generated.
The Java Virtual Machine then processes this class file to generate machine code. The class file is generated in three steps. In the first step class loader loads the class file along with all the referenced classes. In the second step, the bytecode verifier checks the code to find instructions that may refer to memory locations that are out of the scope of the program. The Bytecode verifier also checks whether all the variables are initialized not. All the function calls are compatible with their object references, all private data and member functions follow JVM specifications. The Bytecode verifier also checks that local variables are maintained in the stack and the stack does not overflow. In the third step, the Just-In-Time-Compiler converts the byte code into machine code.
The main() method in Java Program
The execution of the java program begins with the main( ) method. If the main( ) method is not in the java program then execution of the java program will not take place. The syntax of the java main( ) method is like this:
public static void main(String args[ ])
The public in the above syntax is an access specifier that is responsible for indicating JVM that it is the beginning of the Java program. Static is also a keyword and specifies that this main() function can be called without creating its object. Void specifies that the man( ) method does not return any value. The main() function is defined in the JVM and called upon by JVM to execute the programming instructions within main( ). The main( ) function contains the parameter string args and it is a string array, this parameter accepts the number of strings. This parameter handles command-line arguments. If this parameter is skipped then this java program will compile but will not execute as the definition of the main( ) method in the JVM is with the parameter String args.
Java program without main () method
Java program can be executed without the main( ) method. This can be done using a static block. When a group of statements is placed within a static block then these groups of statements are executed when this static block is loaded into the memory by ClassLoader.