Java SE from sketch - Part 1

History at a glance:
  • In the year around 1990James Gosling along with 13 team members started planning for of computing and formed a team called Green Team.
  • Their primary goal was to control over handheld devices like cable set-top boxes,VCR's, toasters, *7-type of device, and also for personal data assistants (PDA).
  • They came up with a language named OAK with having features with Platform independent, Extremely reliable, Compact.
  • Internet and Web explosion began, so Sun shifted the target market to Internet applications and changed the name of the project OAK to Java.
  • Having passed a bad time since 1991 – 1993, In 1994 Sun's HotJava browser appeared.
  • HotJava illustrated the power of applets, programs that run within a browser, and also the capabilities of Java for speeding program development.
  • In 1995, Netscape Navigator Internet browser incorporated Java technology officially.
  • And Java alpha version Java1.0a2 introduced in the market.
  • Since then now we have Java 6 with 12 update so far
What is Java:
Java is a OOP language which refers with several others language like C, C++ or Pascal having different new perception as

  • Pure OOP language
  • Java byte code
  • JVM (Java Virtual Machine)
  • JRE (Java Runtime Environment)
Java’s ideal features:
Java has incorporated plenty of exiting features to buzz the programming myth, some of are
  • Platform Independency
  • Compiler/Interpreter Pack
  • Automatic Memory Management
  • Architecture neutrality
  • Security

Plaform Independent vs Architecture Neutral:
PI refers to running the programs written in one platform (Operating System) will be the same for other platform. Software specific

AN refers to writing a program for a Machine (e.g. Pentium) will be the same for any other machine architecture. Hardware specific

Byte Code and Binary Machine Code:
Byte code is alternative form of Machine code which is understood only by the JVM generated by java compiler orally known as .class file. When JVM loads a .class file in fact it loads stream of byte code for each method there in the class. And finally execute by java interpreter, JIT (just-in-time) or JVM specific techniques.

Binary code falls a hidden mechanism here in Java where JVM act smart o generate neutral machine code against all Byte Code stream taken from a class file. Mr. Cute JVM act as a Microprocessor here!!!


JVM as Microprocessor:
As name says JVM is a Virtual Machine which has its own instruction sets as Microprocessors does. Each instruction consists of a one-byte opcode followed by zero or more operands. The opcode indicates the action to be taken. If more information is required before the JVM can take the action, that information is encoded into one or more operands that immediately follow the opcode. For each kind of data to be handled either logically or arithmetically JVM does with its own separate instruction a set.

Sample instruction opcodes of JVM :
iconst_m1, iconst_0 , iconst_1
, iconst_1

Sample Byte code Stream :
03 3b 84 00 01 1a 05 68 3b a7 ff f9


Sample Machine code by JVM:
iconst_0 = 03
istore_0 = 3b
iinc 0, 1 = 84 00 01
iload_0 =1a
iconst_2 = 05
imul = 68
istore_0 = 3b
goto -7 = a7 ff f9

Finally to say Java is smart because it has JVM. All praises Java but JVM the hero. Sorry to say JVM not Platform independent because each platform needs a separate JVM.


JDK vs JRE vs JVM:
  • JDK to compile Java Program and generate bytecode
  • JRE to run the Java Program with the help of JVM
  • JVM to interpret Java bytecode to machine code for low level execution.

JDK: Java Development Kit holds all the tools needed to develop the Java programs. These tools are compiler i.e. javac, Java application launcher i.e.java.exe, Appletviewer, etc. If wejust needed to write a Java program and compile then JDK is enough.

JRE: Java Runtime Environment contains JVM, class libraries, and other supporting files. Actually JVM runs the program, and it uses the class libraries, and other supporting files provided in JRE.

JVM: Java Virtual Machine interprets the bytecode into the machine code depending upon the underlying operating system and hardware combination. It is responsible for all the things like garbage collection, array bounds checking, etc.


Java Exceution processes:
Compiling (JDK part):
My.java--->javac My.java (Compiling)--->My.class (Bytecode)

Executing (JRE part):
java My (Interpreting)--->JVM---> Machine Code--->Microprocessor---> Output

0 comments:

Post a Comment