Monday, March 17, 2014

Few terminologies to be familiar with, before leaping into Java Programs

“If debugging is the process of removing software bugs, then programming must be the process of putting them in.”
- Edsger Dijkstra


What JAVA Comprise of ?
Apart from this internal architecture Java architecture arise from following distinct and interrelated technologies :
  • the Java programming language  
  • the Java class file format 
  • the Java Application Programming Interface 
  • the Java Virtual Machine
You express the program in source files written in the Java programming language, compile the source to Java class files, and run the class files on a Java Virtual Machine. When you write your program, you access system resources by calling methods in the classes that implement the Java Application Programming Interface, or Java API. As your program runs, it fulfills your program's Java API calls by invoking methods in class files that implement the Java API

JAVA Platform 
  1. The combination of the Java Virtual Machine and Java API constitute the Java Platform and called as Java run-time system. 
  2. The platform is not specific to any one processor or operating system, but rather an execution engine called virtual machine and a compiler with a set of standard libraries that are implemented for various hardware and operating systems so that Java programs can run identically on all of them.
  3. The essential components in the platform are the Java language compiler, the libraries, java language itself (Java API) and the run-time environment in which Java intermediate byte-code “executes” according to the rules laid out in the virtual machine specification. 
JVM (java virtual machine) 
  • The Java Virtual Machine is an abstract computer means a machine within a machine which  mimics a real Java processor, enabling Java bytecode to be executed as actions or operating system calls on any processor regardless of the operating system.
  • But you should remember jvm is that part of java which is written in procedural language and it is platform dependent but the bytecode that jvm accepts is platform independent. 
The main function of jvm are as follows :
  • Loading of class files (compiled java source code).
  • Verification of class files i.e., Class files should contain valid byte-code.
  • Interpretation of byte code and then run the program .
  • The Java Virtual Machine contains a class loader, which loads class files from both the program and the Java API. Only those class files from the Java API that are actually needed by a running program are loaded into the virtual machine.
  • The bytecodes are executed in an execution engine. On a Java Virtual Machine implemented in software, the simplest kind of execution engine just interprets the bytecodes one at a time. Another kind of execution engine, one that is faster but requires more memory, is a just-in-time compiler.
  • In this scheme, the bytecodes are compiled to native machine code the first time the method is invoked. The native machine code for the method is then cached, so it can be re-used the next time that same method is invoked. On a Java Virtual Machine built on top of a chip that executes Java bytecodes natively, the execution engine is actually embedded in the chip .
  • When running on a Java Virtual Machine that is implemented in software on top of a host operating system, a Java program interacts with the host by invoking native methods.
  •  In Java, there are two kinds of methods: Java and native. A Java method is written in the Java language, compiled to bytecodes, and stored in class files. A native method is written in some other language, such as C, C++, or assembly, and compiled to the native machine code of a particular processor. 
  • Native methods are stored in a dynamically linked library whose exact form is platform specific. While Java methods are platform independent, native methods are not. When a running Java program calls a native method, the virtual machine loads the dynamic library that contains the native method and invokes it.One native method interface--the Java Native Interface, or JNI--enables native methods to work with any Java Platform implementation on a particular host computer.
JIT (Just-In-Time)
 
  • Just-In-Time compiler exists within the Java Virtual Machine or JVM. 
  • Java source files are compiled by the Java compiler into platform independent bytecode or Java class files.
  • After you fire your Java application, the JVM loads the compiled classes at run time and execute the proper computation semantic via the Java interpreter.
  • When JIT is enabled, the JVM will analyze the Java application method calls and compile the bytecode (after some internal thresholds are reached) into native, more efficient, machine code. The JIT process is normally prioritized by the busiest method calls first.
  • Once such method call is compiled into machine code, the JVM executes it directly instead of “interpreting” it.
  • The above process leads to improved run time performance over time.
JDK(Java Development Kit) 

The Java Development Kit(JDK) is bundle of software that can be used to develop Java based software. Typically, each JDK contains documentation, examples, installation instructions, class libraries and packages, one (or more) JRE’s along with the various development tools like the Java source compilers, bundling and deployment tools, debuggers, development libraries, etc

JRE (Java Runtime Environment)

Java Runtime Environment contains JVM, class libraries, and other supporting files. It does not contain any development tools such as compiler, debugger, etc. JVM runs the program, and it uses the class libraries, and other supporting files provided in JRE. JRE is enough if the intention is only to run a java program but not to write / compile own programs.

              JRE
                    JDK
It is an implementation of java virtual machine, which executes java programs.
It is bundle of software that is needed to build java
based application.
It includes the JVM, Core libraries and other additional components to run applications and applets.
It includes the JRE, set of API classes, Java compiler, Webstart and additional files needed to write Java applets and applications.
The JRE is smaller than the JDK so it needs less Disk space
The JDK needs more Disk space as it contains the JRE along with various development tools.


JAVA SE  (java platform standard Edition)

Java Platform Standard Edition (JavaSE) is equivalent to JDK. It was called as JDK earlier. When people say JDK1.6, it means version JavaSE SDK 1.6.0.
JavaSE consists of a virtual machine (JVM) as part of a JRE which must be used to run Java programs and a set of libraries or “packages” (JDK) needed to use file systems, networks, graphical interfaces, and so on.

Java SE was known as Java 2 Platform Standard Edition or J2SE from version 1.2 until version 1.5. The “SE” is used to distinguish the base platform from Java EE (Java Enterprise Edition)and Java ME (Java Mobile Edition). The “2″ was originally intended to emphasize the major changes introduced in version 1.2, but was removed in version 1.6.

The naming convention has been changed several times over the Java version history. Starting with J2SE 1.4 (Merlin) to J2SE 5.0 (Tiger) to Java SE 6 (Mustang).

The Java Class File
The class file is generated after compilation of the Java source file (.java file)
The Java class file makes java platform-independence and network-mobile. Its role in platform independence is serving as a binary form for Java programs that is expected by the Java Virtual Machine but independent of underlying host platforms. This approach breaks with the tradition followed by languages such as C or C++.
 
The Java API
  • The Java API is set of runtime libraries that give you a standard way to access the system resources of a host computer.
  • When you write a Java program, you assume the class files of the Java API will be available at any Java Virtual Machine . Java Virtual Machine and the class files for the Java API are the required components of any implementation of the Java Platform. 
  • When you run a Java program, the virtual machine loads the Java API class files that are referred to by your program's class files. The combination of all loaded class files (from your program and from the Java API) and any loaded dynamic libraries (containing native methods) constitute the full program executed by the Java Virtual Machine.
  • In addition to facilitating platform independence, the Java API contributes to Java's security model. 
  • The methods of the Java API, before they perform any action that could potentially be harmful (such as writing to the local disk), check for permission from the security manager.
  • The security manager is a special object that a Java application can instantiate that defines a custom security policy for the application. 
  • A security manager could, for example, forbid access to the local disk. If the application requested a local disk write by invoking a method from the Java API, that method would first check with the security manager. Upon learning from the security manager that disk access is forbidden, the Java API would refuse to perform the write

JavaDoc

The Javadoc tool provided by Sun is used to produce documentation for an application or program.

JAR 

A Jar (Java Archive) file is used to group together related class files into a single file for more compact storage, distribution, and transmission. Its much like a zip file with .jar extension.
  
-KEEP LEARNING, HAPPY CODING


No comments:

Post a Comment